We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51020
    • 670 Posts
    Quote from: BobRay at Nov 20, 2017, 11:02 PM
    Oops. I can see why (no quotes around ArticlesContainer), but I realized that the ArticlesContainer is already visible, so try this version:

    /* FixArticles Snippet */
    $docs = $modx->getCollection('modResource', array('class_key' => 'Article'));
    
    $count = 0
    foreach ($docs as $doc) {
        $count++;
        $doc->set('show_in_tree', true);
        $doc->set('hide_children_in_tree', false);
        $doc->set('deleted', true); // optional
        $doc->save();
    }
    
    return '<h3>Altered ' . $count . ' Resources</h3>';
    

    Thanks Bob - I added a ; after $count = 0, as I think that should be there?
    I just ran that by viewing the resource, but it came back with:

    Altered 0 Resources

    So strange - nothing I try seems to find these resources in the database!
    • discuss.answer
      • 3749
      • 24,544 Posts
      That may be because the Articles class and map files are gone, so MODX/xPDO doesn't know that an Article extends modResource.

      I would back up the DB with Export in PhpMyAdmin (if you haven't already) before running the query below.

      This is probably the fastest and most reliable (if I have it correct). Just go into PhpMyAdmin, open the MODX DB, put this line in the query input on the SQL tab, and click on "Go" (or "Simulate Query" first, to make sure it finds records):

      UPDATE `modx_site_content` SET `show_in_tree`='1', `hide_children_in_tree`='0', `deleted`='1' WHERE class_key='Article'


      Change the prefix on modx_site_content if your site uses a different prefix.

      You can run it again with 'ArticlesContainer' at the end instead of 'Article' to modify the container.

        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
        • 51020
        • 670 Posts
        Quote from: BobRay at Nov 22, 2017, 08:26 PM
        That may be because the Articles class and map files are gone, so MODX/xPDO doesn't know that an Article extends modResource.

        I would back up the DB with Export in PhpMyAdmin (if you haven't already) before running the query below.

        This is probably the fastest and most reliable (if I have it correct). Just go into PhpMyAdmin, open the MODX DB, put this line in the query input on the SQL tab, and click on "Go" (or "Simulate Query" first, to make sure it finds records):

        UPDATE `modx_site_content` SET `show_in_tree`='1', `hide_children_in_tree`='0', `deleted`='1' WHERE class_key='Article'


        Change the prefix on modx_site_content if your site uses a different prefix.

        You can run it again with 'ArticlesContainer' at the end instead of 'Article' to modify the container.

        Just noticed I hadn't replied on this - it worked - the resources have now finally gone, and the error has stopped showing - thank you and apologies for not responding earlier. It's much appreciated.

        Andy