-1

I'm finding that the resources for doing this are sparse. I'm using MODX as a CMS and want to take my existing blogs from Wordpress and use them in the new CMS. The resources are abundant for going from MODX to WP, but there's only one published method for WP to MODX, using the Articles method, which unfortunately doesn't work anymore. Whether that is because Articles hasn't been updated or the XML file from WP is incompatible.

Anyway, I'm left now with trying to do this the old fashioned way and I will not be able to bring each article over one-by-one. I want to learn how to take the exported XML file from WP and parse it into MODX, probably using PHP. But I'm unsure where to start.

Any suggestions would be helpful...yes I tried Google already. I'm not sure what to start with.

Thanks!

Jeff Sydor
  • 307
  • 1
  • 10

1 Answers1

0

getFeed snippet code can be helpful for you here. You can take it's code, modify a bit and process WP feed items, something like the next:

if (!empty($url) && $modx->getService('rss', 'xmlrss.modRSSParser')) {
    $rss = $modx->rss->parse($url);
    if (!empty($rss) && isset($rss->items)) {
        while (list($itemKey, $item) = each($rss->items)) {
            foreach ($item as $k => $v) {
                $item[$k] = str_replace(array('[',']'),array('[',']'),$item[$k]);
            }
            /// process rss items here  
            // f.e. add new modx resources
            $newArticle = $this->modx->newObject('modResource'); //new article
            $newArticle->set( 'template', ARTICLE_TEMPLATE_ID ); // replace ARTICLE_TEMPLATE_ID with actual article template id
            $newArticle->set( 'pagetitle', $item['title'] ); // pagetitle
            $newArticle->set( 'parent', ARTICLE_CONTAINTER_ID);
            $newArticle->set( 'content', $item['description'] );

            //add other valuable fields

            if(!$newArticle->save()){
                // modx error
            }

    }
}
Anton Tarasov
  • 534
  • 1
  • 7
  • 16