$ams_topics = $mytree->getChildTreeArray(0,'weight'); foreach($ams_topics as $one_amstopic) { // First we create the topic $topicpid=0; if($one_amstopic['topic_pid']!=0) { // Search for its the parent if(array_key_exists($one_amstopic['topic_pid'],$ams_news_topics)) { $topicpid=$ams_news_topics[$one_amstopic['topic_pid']]; } } $news_topic = new nw_NewsTopic(); $news_topic->setTopicPid($topicpid); $news_topic->setTopicTitle($one_amstopic['topic_title']); $news_topic->setTopicImgurl($one_amstopic['topic_imgurl']); $news_topic->setMenu(0); $news_topic->setTopicFrontpage(1); $news_topic->Settopic_rssurl(''); $news_topic->setTopicDescription(''); $news_topic->setTopic_color('000000'); $news_topic->store(); echo '<br>- The following topic was imported : '.$news_topic->topic_title(); $ams_topicid = $one_amstopic['topic_id']; $news_topicid = $news_topic->topic_id(); $ams_news_topics[$ams_topicid] = $news_topicid; // Then we insert all its articles $result = $db->query('SELECT * FROM '.$ams_articles.' WHERE topicid='.$ams_topicid.' ORDER BY created'); while ( $article = $db->fetchArray($result) ) { $ams_newsid = $article['storyid']; // We search for the last version $result2 = $db->query('SELECT * FROM '.$ams_text.' WHERE storyid='.$ams_newsid.' AND current=1');