We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 43550
    • 26 Posts
    Hi all,

    I manually added some pages to the database table but they are not showing up in the manager. I have tried clearing caches etc but nothing seems to help. The parent id is definitely an existing folder. I can alter the manager url and edit the pages and save them, I can manually create the url to access the pages on the public website too. To all intents and purposes the pages exist, are real and fully working.

    But I cannot get them to appear in the manager resources panel.

    Does anyone know what I might be doing wrong?

    Thank you for your help,

    Best wishes,

    Paul.
      • 32699 ☆ A M B ☆
      • 427 Posts
      Quote from: pauld123 at Feb 22, 2014, 11:30 AM
      Hi all,

      I manually added some pages to the database table but they are not showing up in the manager.

      I have to assume when you added them to the table you did not set their context, and a few other settings.

      What you may have wanted to do, was to dump the pages from the old database (assumption here) into a php array (myphpadmin does this).

      place the array in a snippet

      and run a for loop on the array with



      $arrayItems = array(
      
      /* long list of stuff here from phpmyadmin export
      
      */ );
      
      
      foreach ($arrayItems as $page){
      if ($page){
      $resourceObj = $modx->newObject('modResource', $page);
      $resourceObj->save();
      }
      


      You will have to search/replace the array keys to match the modx stuff. I would dump the primary key on the incoming dataset and let modx create new ones, though you can always use them if you wish.


      BTW don't forget to dump the pages you manually added first.
        Get your copy of MODX Revolution Building the Web Your Way http://www.sanitypress.com/books/modx-revolution-building-the-web-your-way.html

        Check out my MODX || xPDO resources here: http://www.shawnwilkerson.com
        • 43550
        • 26 Posts
        Thanks for the detailed answer.

        Not certain what is going on there exactly. Before I saw your answer I decided to spend 20 mins adding the pages manually and then altering them in the database table once the system recognized the pages.

        I was hoping to generate pages through a third party system that I was then going to write into the table. I checked all the other tables but could not find any other references to the resources that would explain the issue. (There are good reasons for doing this).

        I do it for chunks but perhaps I will have to rethink my idea. Perhaps I should spend some time learning the XPDO stuff.

        Thank you again,

        Best wishes,

        Paul.

          • 3749
          • 24,544 Posts
          Yes, it's almost never a good idea to alter the MODX database directly except to fix problems, especially with resources, which have many fields that have to be set correctly. There are also potential intersects that need to be set (e.g. modContextResource).

          It's relatively easy to do it in code:

          $fields = array(
              'pagetitle' => 'SomeTitle',
              'alias' => 'some-title',
              'longtitle' => 'something',
              'introtext' => 'something',
              'context_key' => 'web',
              'show_in_tree' => true,
              'content' => '<p>This is the document content</p>',
              // or 
              // 'content' => file_get_contents('path/to/file');
          );
          
          $modx->runProcessor('resource/create', $fields);
            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
            • 43550
            • 26 Posts
            That is very helpful, thank you BobRay.

            Best wishes,

            Paul.