diff --git a/library/Class/CustomField/Value.php b/library/Class/CustomField/Value.php
index 328a16985b2929a0e11b1e533dd6f9200f20ac2c..a9abe17514b89bd664789237e44dea72c5d32f47 100644
--- a/library/Class/CustomField/Value.php
+++ b/library/Class/CustomField/Value.php
@@ -32,6 +32,7 @@ class Class_CustomField_ValueLoader extends Storm_Model_Loader {
 
 
 	public function findAllByInstance($instance) {
+		xdebug_break();
 		$model = Class_CustomField_Model::getModel(get_class($instance));
 		$fields = $model->getFields();
 		$field_ids = array_map(function($f) {return $f->getId();},
diff --git a/library/Class/Import/Typo3.php b/library/Class/Import/Typo3.php
index 8c5a13b3ef5dee04b1340801304038572f95325c..22681c9577316a0436a94b1d671d3df3bd1fae77 100644
--- a/library/Class/Import/Typo3.php
+++ b/library/Class/Import/Typo3.php
@@ -30,7 +30,8 @@ class Class_Import_Typo3 {
 	const  FOREIGN_UID_DATETIME=[867,36];
 	protected
 		$user_mapper,
-		$unknown_koha_urls = [];
+		$unknown_koha_urls = [],
+		$meta;
 
   public function __construct() {
     $this->t3db = new Typo3DB();
@@ -51,8 +52,43 @@ class Class_Import_Typo3 {
     $this->errors = [];
     $this->domaine_map = new DomaineMap();
 		$this->userMap = new UserMap();
+		$this->createCustomField();//		Class_CustomField_model::register(new Class_CustomField_modelConfiguration('
+
+
   }
 
+
+	public function getMeta() {
+		xdebug_break();
+
+		if ($this->meta=Class_CustomField_Meta::findFirstBy(['label' => 'uid_typo3']))
+			return $this->meta;
+		$this->meta=Class_CustomField_Meta::newInstance(
+																											[
+																											 'label' => 'uid_typo3',
+																											 'field_type' => Class_CustomField_Meta::TEXT_INPUT,
+																											 'options_list' => '']);
+		$this->meta->save();
+
+		return $this->meta;
+	}
+
+	public function createCustomField() {
+		$this->meta=$this->getMeta();
+		if ($this->custom_field_article=Class_CustomField::findFirstBy(['meta_id' => $this->meta->getId(),
+																																		'model' => 'Article']))
+			return $this->custom_field_article;
+		$this->custom_field_article=Class_CustomField::newInstance([
+																																'meta_id' => $this->meta->getId(),
+																																'priority' => 1,
+																																'model' => 'Article']);
+		$this->custom_field_article->save();
+		return $this->custom_field_article;
+
+
+	}
+
+
 	public function setTypo3DB($t3db) {
 		$this->t3db=$t3db;
 		return $this;
@@ -298,6 +334,44 @@ class Class_Import_Typo3 {
 	}
 
 
+	public function updateCategoriesForDossiersDocumentaires() {
+		$t3_pages = $this->t3db->findAllPagesWithPid(309);
+		foreach ($t3_pages as $page) {
+			$category = $this->createCategory($page['title'],36);
+
+			$contents = $this->t3db->findAllContents($page['uid']);
+			foreach ($contents as $content) {
+				$article = $this->_getArticle($content['uid']);
+				$article->setCategorie($category);
+				$article->save();
+			}
+		}
+
+	}
+
+
+	protected function _getArticle($value) {
+		$this->meta=$this->getMeta();
+		$custom_field=Class_CustomField::findFirstBy(['meta_id' => $this->meta->getId()]);
+
+		$value = Class_CustomField_Value::findFirstBy(['custom_field_id' => $custom_field->getId(),
+																									 'value' => $value]);
+
+		return Class_Article::find($value->getModelId());
+
+	}
+
+
+	public function findArticle($uid) {
+				return Class_Article::findFirstBy(['uid_typo3' => $uid]);
+		$model_values = $this->_getCustomFieldModelValues($model);
+		$custom_form = $this->_getCustomFieldForm($model_values);
+		return $this->_getFormWith($model, $custom_form);
+//		return $model
+
+	}
+
+
   public function importArticles() {
     $t3news = $this->t3db->findAllArticles();
     foreach($t3news as $new) {
@@ -340,6 +414,18 @@ class Class_Import_Typo3 {
 			$article->setIdCat($this->news_categories_map->find($id_cat)->getId());
 	}
 
+	public function saveUidForModel($model,$model_id,$uid) {
+		$model = Class_CustomField_Model::getModel($model);
+
+		$model_values= $model->find($model_id);
+
+		$model_values->setFieldValue(Class_CustomField::findFirstBy(['model'=> 'Article'])->getId(), $uid);
+		return $model_values->save();
+
+//		if ($model_values->customizedModelIsNew()) {
+
+
+	}
 
 	public function createArticle($new,$id_cat) {
 		$date_creation = date("Y-m-d H:i:s", $new['crdate']);
@@ -364,6 +450,7 @@ class Class_Import_Typo3 {
 			return $element;
 
 		}
+		$this->saveUidForModel('Article', $element->getId(),$new['uid']);
 		Class_Import_Typo3_Logs::getInstance()->incrementArticlesSaved();
 		return $element;
 	}
@@ -424,7 +511,7 @@ class Class_Import_Typo3 {
         Class_Import_Typo3_Logs::getInstance()->addErrorRow('calendar with uid: ' . $new['uid'] . '(' . $new['title'] . ') - ' . implode(', ', $element->getErrors()));
         return $element;
       }
-
+			$this->saveUidForModel('Article', $element->getId(),$new['uid']);
 			$element->setDateCreation($date_creation)->save();
 
       $this->report['calendar_created']++;
@@ -436,6 +523,14 @@ class Class_Import_Typo3 {
 	}
 
 
+	public function createCategory($category_name) {
+		if ($category=Class_ArticleCategorie::findFirstBy(['libelle' => $category_name]))
+			return $category;
+    $category=Class_ArticleCategorie::newInstance(['libelle' => $category_name,'id_cat_mere' =>36]);
+		$category->save();
+    return $category;
+	}
+
   public function importArticlesPages() {
     $rows = $this->t3db->findAllContents();
 
@@ -475,6 +570,7 @@ class Class_Import_Typo3 {
 			$this->report['pages_errors']++;
 			Class_Import_Typo3_Logs::getInstance()->addErrorRow('pages with uid: ' . $new['uid'] . ' (' . $new['title'] . ') - ' . implode(', ', $element->getErrors()));
 		}
+		$this->saveUidForModel('Article', $element->getId(),$new['uid']);
 		return $element;
 	}
 
@@ -797,6 +893,12 @@ class Typo3DB {
 		return $this->pages_titles[$uid] = $row['title'];
 	}
 
+
+	public function findAllPagesWithPid($pid) {
+		return $this->t3db->fetchAll('select * from pages where pid='.$pid);
+	}
+
+
 	public function findAllUsers() {
 		return $this->t3db->fetchAll('select * from be_users where uid > 1');
 	}
@@ -830,8 +932,11 @@ class Typo3DB {
 		return $this->t3db->fetchAll("select * from tx_cal_event where deleted=0 and hidden=0 order by uid ASC");
 	}
 
-	public function findAllContents() {
-		return $this->t3db->fetchAll("select * from tt_content where deleted=0 and hidden=0 and header>'' and bodytext>'' and  (ctype='text' or ctype='textpic') order by uid ASC");
+	public function findAllContents($page_id=false) {
+		$pid_sql='';
+		if ($pid)
+			$pid_sql='and pid='.$page_id;
+		return $this->t3db->fetchAll("select * from tt_content where deleted=0 and hidden=0 and header>'' and bodytext>'' and  (ctype='text' or ctype='textpic') ".$pid." order by uid ASC");
 	}
 }
 ?>
\ No newline at end of file
diff --git a/tests/library/Class/Import/Typo3Fixture.php b/tests/library/Class/Import/Typo3Fixture.php
index d309576ce34348e52d34e2f84a54cfe2eb5a8e77..9f210f332349d20bf4280c0fa8029a606afd0af4 100644
--- a/tests/library/Class/Import/Typo3Fixture.php
+++ b/tests/library/Class/Import/Typo3Fixture.php
@@ -302,7 +302,6 @@ La collection<span style="text-decoration: none"><span style="font-style: normal
 	}
 
 	public function findAllForeignUidForNewsCat($uid) {
-		xdebug_break();
 		if ($uid==14488)
 			return [[ 'uid_foreign' => 867 ]];
 
@@ -391,7 +390,7 @@ La collection<span style="text-decoration: none"><span style="font-style: normal
 		];
 	}
 
-	public function findAllContents() {
+	public function findAllContents($page_id=false) {
 		return [
 						[
 						 'uid' => 32,
@@ -409,6 +408,12 @@ La collection<span style="text-decoration: none"><span style="font-style: normal
 	}
 
 
+	public function findAllPagesWithPid($pid) {
+		if ($pid==309)
+			return [ [ 'uid' => 32,
+								'title' => 'BLOGS AND SITES' ]];
+		return [];
+	}
 	public function findPageTitle($uid) {
 		if ($uid == 49)
 			return '2014';
diff --git a/tests/library/Class/Import/Typo3Test.php b/tests/library/Class/Import/Typo3Test.php
index 9dee0730752eadb16f5aa14f9f2fc544c55cc3d6..903a7bc0d9c5d9f9b6e4b8fad88c5964910b9a16 100644
--- a/tests/library/Class/Import/Typo3Test.php
+++ b/tests/library/Class/Import/Typo3Test.php
@@ -30,7 +30,6 @@ abstract class Import_Typo3TestCase extends ModelTestCase {
 	public function setUp() {
 		parent::setUp();
 		Class_Import_Typo3_Logs::getInstance()->cleans();
-
     Class_Article::beVolatile();
     Class_Users::beVolatile();
     Class_ArticleCategorie::beVolatile();
@@ -38,15 +37,43 @@ abstract class Import_Typo3TestCase extends ModelTestCase {
     Class_CodifThesaurus::beVolatile();
     Class_Sitotheque::beVolatile();
     Class_SitothequeCategorie::beVolatile();
+
+		Class_CustomField_Model::registerAll([
+																					new Class_CustomField_ModelConfiguration_Article()
+
+																					 ]);
+
+		Class_CustomField_Meta::beVolatile();
+		Class_CustomField::beVolatile();
+		Class_CustomField_Value::beVolatile();
 		$this->mock_sql = Storm_Test_ObjectWrapper::mock();
 		$this->old_sql = Zend_Registry::get('sql');
 		Zend_Registry::set('sql', $this->mock_sql);
 
 		$this->mock_sql->whenCalled('execute')
 									 ->answers(true);
+		$this->fixture('Class_CustomField_Meta',
+									 ['id' => 1,
+										'label' => 'uid_typo3',
+										'field_type' => Class_CustomField_Meta::TEXT_INPUT,
+										'options_list' => '']);
+
+
+		$this->fixture('Class_CustomField',
+									 ['id' => 1,
+										'meta_id' => 1,
+										'priority' => 1,
+										'model' => 'Article']);
+
 		$this->migration = new Class_Import_Typo3();
 		$this->migration->setTypo3DB(new MockTypo3DB());
+/*		$this->fixture('Class_CustomField_Value',
+									 ['id' => 25,
+										'custom_field_id' => 1,
+										'model_id' => 1,
+										'value' => 'enabled']);
 
+*/
 	}
 
 
@@ -489,9 +516,41 @@ class Import_Typo3SitothequeTest extends Import_Typo3TestCase {
 		$this->assertEquals('/miop-test.net/recherche/viewnotice/clef/OUEST_CANADIEN', Class_Sitotheque::findFirstBy(['titre' => 'L\'ouest canadien'])->getUrl());
 
 	}
+
 }
 
+class Import_Typo3CustomFieldTest extends Import_Typo3TestCase {
+	public function setUp() {
+		parent::setUp();
+		$this->migration->import_categories();
+		$this->migration->importArticles();
+
+		$this->migration->importArticlesPages();
+  	Class_CustomField_Value::clearCache();
+		$this->fixture('Class_ArticleCategorie', ['id' => 36,
+																							'libelle' => 'Dossiers Documentaires']);
+		$this->migration->updateCategoriesForDossiersDocumentaires();
+
+
+	}
+		/** @test */
+	public function museoShouldHaveCustomField() {
+  	Class_CustomField_Value::clearCache();
+		$article=Class_Article::findFirstBy(['titre' => 'A haute voix... le roman se fait entendre...']);
+ 		$this->custom_field_values = Class_CustomField_Value::findAllByInstance($article);
+		$this->assertEquals(32,$this->custom_field_values[0]->getValue());
+	}
+
 
+	/** @test */
+	public function updateCategoriesShouldUpdateCategorie() {
+		$this->assertEquals('BLOGS AND SITES',Class_Article::find(9)->getCategorie()->getLibelle());
+	}
+	/** @test */
+	public function updateCategorieShouldUpdateParentCategorie() {
+		$this->assertEquals('Dossiers Documentaires',Class_Article::find(9)->getCategorie()->getParent()->getLibelle());
+	}
+}
 
 class Import_Typo3ContentTest extends Import_Typo3TestCase {
 	public function setUp() {