We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9889
    • 7 Posts
    Looking to put up a large site with Revo 2.0.4 ...

    Is there an easy and quick way to create a large number of resources (pages) without having to create them one by one?

    I found "Superpage" in the Addons directory but it doesn’t work with Revo - http://modxcms.com/extras/package/?package=438

    Perhaps any way to do this through directly manipulating the database?

    Thanks!
      • 1169
      • 312 Posts
      You could import pages via CSV with phpmyadmin there are posts describing this try google for modx revolution csv. You would have to know what fields you could match to your data.
      Definitely doable.
        DEVELOPMENT ENV:- Ubuntu 12.04 | MODx Revolution 2.2.8 | LAMP 2i Apache 2.2.22 | Php 5.3.10 | Mysql 5.5.31 MySQL client version: 5.5.31
        • 31037
        • 358 Posts
        I’m not sure, did you want to import a number of pages or did you want to auto create some pages for testing? If only for testing you can use this little snippet:
        <?php
          //Snippet [[createResources]] by Uncle68
          $createInFolder = 0; //Set to 0 to create main folders in root, or set an existing folders id
          $parents = 4; // Number of parents to create or 0 to just create children
          $children = 25; // Number of children to create
          $template = 0; // Chose template for new docs
          $published = 1; // Published or not
         
          $output ='';  
        
          
          if ($parents)  {
          $x=1;$p=0;
          $output .= '<p><strong>Creating ' . $parents . ' parents/folders.</strong></p><p>'; 
            while ($p < $parents) {
              $foldertitle = 'Folder ' . $x;
              $content = 'Content ' . $x;
              
              $par = $modx->newObject('modResource');
              $par->set('pagetitle', $foldertitle);
              $par->set('content', $content);
              $par->set('published', $published); 
              $par->set('isfolder', 1); 
              $par->set('template', 2);
              if ($modx->getObject('modResource',$createInFolder)) { 
               $par->set('parent', $createInFolder);
              }
              $par->save();
              $newParents[] = $par->get('id');
              $output .= 'Created parent/folder: ' . $par->get('pagetitle') . '<br />' ;
              $p++;
              $x++;
            }
          $output .= '</p>';
          } 
        
          
          $x=1;$c=0;
          $output .= '<p><strong>Creating ' . $children. ' children.</strong></p><p>'; ;
        while ($c < $children) {
          $childtitle = 'Child ' . $x;
          $content = 'Content ' . $x;
          
          $child = $modx->newObject('modResource');
          $child->set('pagetitle', $childtitle);
          $child->set('content', $content);
          $child->set('published', $published); 
          if (!$newParents) { $prn = $createInFolder;
          } else {
            shuffle($newParents);
            $prn = $newParents[0];
          }
          $child->set('parent', $prn); 
          $child->set('template', 2);  
          $child->save();
          $newChildren[] = $child->get('id'); //Use if you want to create children to children
          $output .= 'Created child: ' . $child->get('pagetitle') . ' with parent ' . $prn . '<br />' ;
          $c++;
          $x++;
        }
          $output .= '</p>';
          
          return $output;
        With some modifications it could be used for importing from an array or textfile too I guess...

        Create a snippet called "createResources" and call if from a page in front end.
          • 9550
          • 123 Posts
          allanb: any idea where you saw how to do this? Google gave me no love for "modx revolution csv," except this post. Would love to be able to batch import resources.
            • 37210
            • 131 Posts
            Check this out:

            http://modx.com/extras/package/importx

            Just found it and I’m going to try it out now.
              • 1169
              • 312 Posts
              Sorry for not replying earlier must have missed your post.

              You could try google ’mysql import csv phpmyadmin’ plenty of results
                DEVELOPMENT ENV:- Ubuntu 12.04 | MODx Revolution 2.2.8 | LAMP 2i Apache 2.2.22 | Php 5.3.10 | Mysql 5.5.31 MySQL client version: 5.5.31
                • 37210
                • 131 Posts
                Hi Allan,

                I think you reposted the same info!

                I’ve actually found an awesome solution for this issue.

                Check out ’ImportX’ in the Extras.
                  • 1169
                  • 312 Posts
                  Hi Sarah

                  I was not trying to reply to you per say

                  I have no knowledge of ImportX.

                  I was sugesting googling ’mysql import csv phpmyadmin’ as against my first suggestion of ’modx revolution csv’

                  I have successfully used phpmyadmin to achieve this.
                    DEVELOPMENT ENV:- Ubuntu 12.04 | MODx Revolution 2.2.8 | LAMP 2i Apache 2.2.22 | Php 5.3.10 | Mysql 5.5.31 MySQL client version: 5.5.31
                    • 37210
                    • 131 Posts
                    Oh soz.

                    Well either way, anything else is better than manually creating a hundred resources one by one!
                      • 9889
                      • 7 Posts
                      I have messed with phpmyadmin as well to try to import data into MODX (feels somewhat "old school"), tough good to know there is dedicated solution as well - thanks for the link to ImportX!