We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38547
    • 98 Posts
    I installed Articles and tried to imported all child pages under document 2 (the old blog)

    Not sure what i did wrong but it imported every page on the site and I cat see a way of exporting or moving these back as normal documents.

    Can this be done.

    I am using Revo 2.2.7 and Articles 1.6.5

    Many thanks

    Ian
      • 22840
      • 1,572 Posts
      Did you have a database backup ?, other than that try dragging and dropping, hopefully that will work but not having it installed I can't test.
        • 38547
        • 98 Posts
        Quote from: paulp at Apr 13, 2013, 12:25 PM
        Did you have a database backup ?, other than that try dragging and dropping, hopefully that will work but not having it installed I can't test.

        I did not backup and it appears not to be recoverable so I had to re-create the pages and update stuff to reflect the new page ID's so that was fun.

        I think where I went wrong was when i imported the pages I was put the container id in of the existing blog in the Articles form field and followed it with a comma, as there was no number ofter this I think the articles script treated that as a wild card and imported everything so I can honestly say you really might not want to do that.

        Cheers
          • 38290
          • 712 Posts
          I wouldn't advise doing anything without a database backup to go back to but if you examine the site_comtent table you should notice an Article is just a resource with a class key of modArticle. Changing that back to modResource and maybe adjusting some parents should have those back to normal resources.
            jpdevries
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            You also might have to change their "show_in_tree" from 0 to 1.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 37261 ☆ A M B ☆
              • 113 Posts
              We just had a client try to move an Article from one Articles to another using Import which went horribly wrong. They imported half the rest of their site into Articles with no easy way to get it back. Fortunately they are on MODX Cloud and didn't lose much.

              I tried to restore one resource with Batcher before realizing how large of a task it would be. I was able to get the resource to show up in the tree but it threw an error whenever it was read...probably because of the class key. The Articles import feature needs to be a little more forgiving, maybe with a preview of what will be imported before actually committing to it. I suppose the VersionX package would've been able to roll them back once I got them out of Articles but I did not try it.
                • 3749
                • 24,544 Posts
                Slight correction: the classKey for Articles is 'Article'


                If there is a way to identify the Articles (e.g., by parent or classKey), you can write utility snippet to fix them.

                By parent:

                <?php
                $parentId = 12;
                
                $object = $modx->getObject('modResource', $parentId);
                $children = $object->getMany('Children');
                $count = count($children);
                foreach ($chilren as $child) {
                    $child->set('classKey', 'Article');
                    $child->save();
                } 
                
                return 'Corrected classKey of ' . $count . ' resources';
                



                By classKey:

                <?php
                $correctParentID = 22;
                
                $docs = $modx->getCollection('modResource', array('classKey' => 'Article'));
                $count = count($docs);
                foreach ($docs as $doc) {
                    $doc->set('parent', $correctPartentId);
                    $doc->save();
                }
                
                return 'Corrected parent of ' . $count . ' resources';


                If the classKey and the parent are wrong and there's no other way to identify the articles (say, by something in the content, description, or introtext), you're pretty much SOL.

                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting