We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25551 ☆ A M B ☆
    • 1,231 Posts
    Thanks a lot for replying.

    Unfortunately this didn’t work. IN the database there is no added documents to the document_groups table.

    Ross

    EDIT : There is something which might explain why it never worked

    id document_group document
    44 2 32
    43 2 68
    45 2 69
    46 2 38
    52 2 0

    Document 0? Sorry the table above is a bit out of align but I think you can understand it.


    I just ran another test and another line appeared... ID 54 DOC_GROUP 2 Doc 0



    I might of not done this right.

    if($mode=="new"){
    $wuid = ’-’.$user[’internalKey’];
    $table_name = $modx->getFullTableName( ’site_content’ );
    $fields = array(
    ’type’ => ’document’,
    ’contentType’ => ’text/html’,
    ’content’ => ’info text here’,
    ’pagetitle’ => ’main page’,
    ’longtitle’ => ’Main page’,
    ’published’ => ’1’, //is the page published?
    ’parent’ => ’38’, //what is the parent of this new page?
    ’isfolder’ => ’1’, // lets make this a folder
    ’template’ => ’4’, //type template id here
    ’cacheable’ => ’0’,
    ’createdby’ => $wuid,
    ’createdon’ => time(),
    ’editedon’ => time(),
    ’publishedon’ => time(),
    ’hidemenu’ => ’0’,
    ’privateweb’ => ’1’,


    );

    $modx->db->insert( $fields, $table_name); // put the fields in the db (id wil be created incremental.)


    //start of page creation, copy this part and past below for as many docs you want (I know we could use a loop but than the logtitle and page title are all the same)
    $fields = array(
    ’type’ => ’document’,
    ’contentType’ => ’text/html’,
    ’content’ => ’jot call in here’,
    ’pagetitle’ => ’Blog’,
    ’longtitle’ => ’Blog’,
    ’published’ => ’1’, //is the page published?
    ’parent’ => $parent, //here we go create a doc in the first doc
    ’isfolder’ => ’0’,
    ’template’ => ’4’, //type template id here
    ’cacheable’ => ’0’,
    ’createdby’ => $wuid,
    ’createdon’ => time(),
    ’editedon’ => time(),
    ’publishedon’ => time(),
    ’hidemenu’ => ’0’,
    ’privateweb’ => ’1’,

    );

    $modx->db->insert( $fields, $table_name); // put the fields in the db (id wil be created incremental.)
    //end of page creation


    /* grab the last inserted ID so we can set the document group and page id it belongs to*/
    $last_inserted_id = mysql_insert_id();
    $table_name = $modx->getFullTableName( ’document_groups’ );
    $fields = array(
    ’document_group’ => ’2’,
    ’document’ => ’$last_inserted_id()’,
    );
    $modx->db->insert( $fields, $table_name);
    return;
    }
      Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
      AugmentBLU - MODX Partner

      BLUcart - MODX Revolution E-Commerce & Shopping Cart
      • 7455
      • 2,204 Posts
      this: ’document’ => ’$last_inserted_id()’, isnot good
      it needs to be: ’document’ => $last_inserted_id,

      that should work
        follow me on twitter: @dimmy01
        • 25551 ☆ A M B ☆
        • 1,231 Posts
        Thanks Dimmy, that did work but only for the bottom document. When I tried applying it to the others it caused as error.

        Thanks!

        if($mode=="new"){   
        $wuid = '-'.$user['internalKey'];
        	$table_name = $modx->getFullTableName( 'site_content' );
        	$fields = array(
                                'type'	=>  'document',
        			'contentType'	=> 'text/html',
        			'content'	=> '[!sitemap_exclude!]
        <div class="contentcontainer" style="text-align:left; background-color:#444; padding:40px 0 40px 20%">       
        [!Ditto? &tpl=`clientTpl`  &summarize=`15` &total=`9` &sortBy=`createdon` &sortDir=`ASC` &descendentDepth=`3` !]
        </div>
        ',
        			'pagetitle'	=> '[*tvname*]Clan Pages',
        			'longtitle'	=> 'Main Clan Pages Area',
        			'published'	=> '1', //is the page published?
        			'parent'	=> '38', //what is the parent of this new page?
        			'isfolder'	=> '1', // lets make this a folder
        			'template'	=> '4', //type template id here
        			'cacheable'	=> '0',
        			'createdby'	=> $wuid, 
        			'createdon'	=> time(),
        			'editedon'	=> time(),
        			'publishedon'	=> time(),
        			'hidemenu'	=> '0',
        			'privateweb'	=> '1',
        
        			
        			);
        	
        	$modx->db->insert( $fields, $table_name); // put the fields in the db (id wil be created incremental.)
        /* grab the last inserted ID so we can set the document group and page id it belongs to*/
                $last_inserted_id = mysql_insert_id();
                $table_name = $modx->getFullTableName( 'document_groups' );
                $fields = array(
                                'document_group'   =>  '2',
                                'document'    => $last_inserted_id,
                                );
                $modx->db->insert( $fields, $table_name);
        
        //Create  placeholder and put the id in a session to use for mail or whatever.
        $_SESSION['eigenpaginaid'] =  $modx->db->getInsertId();
        $modx->setPlaceholder('eigenpaginaid', $modx->db->getInsertId());
        $parent= $modx->db->getInsertId();
        $settings_table = $modx->getFullTableName( 'web_user_settings' ); //set the table to use
        $fields2 = array('webuser' =>  $user['internalKey'],'setting_name' => 'login_home','setting_value' => $parent); //set the parameters to insert
        $modx->db->insert( $fields2, $settings_table); // insert the parameters in the right table.
        //start of page creation, copy this part and past below for as many docs you want (I know we could use a loop but than the logtitle and page title are all the same)
        $fields = array(
                                'type'	=>  'document',
        			'contentType'	=> 'text/html',
        			'content'	=> '[!sitemap_exclude!]<div class="contentcontainer">
        [!Ditto? &tpl=`clientTpl` &parents=`[*parent*]` &summarize=`15` &total=`9` &sortBy=`createdon` &sortDir=`ASC` &descendentDepth=`3` !]
        [[Jot? &pagination=`10` &captcha=`1` &action=`form,comments` &subjectModerate=`0` &tplComments=`ERRbloghistory`  &tplForm=`ERRblog` ]]</div>',
        			'pagetitle'	=> 'Blog',
        			'longtitle'	=> 'Members Blog',
        			'published'	=> '1', //is the page published?
        			'parent'	=> $parent, //here we go create a doc in the first doc
        			'isfolder'	=> '0',
        			'template'	=> '4', //type template id here
        			'cacheable'	=> '0',
        			'createdby'	=> $wuid,
        			'createdon'	=> time(),
        			'editedon'	=> time(),
        			'publishedon'	=> time(),
        			'hidemenu'	=> '0',
        			'privateweb'	=> '1',
        		
        			);
        	
        	$modx->db->insert( $fields, $table_name); // put the fields in the db (id wil be created incremental.)
        //end of page creation
        /* grab the last inserted ID so we can set the document group and page id it belongs to*/
                $last_inserted_id = mysql_insert_id();
                $table_name = $modx->getFullTableName( 'document_groups' );
                $fields = array(
                                'document_group'   =>  '2',
                                'document'    => $last_inserted_id,
                                );
                $modx->db->insert( $fields, $table_name);
        //start of page creation, copy this part and past below for as many docs you want (I know we could use a loop but than the logtitle and page title are all the same)
        $fields = array(
                                'type'	=>  'document',
        			'contentType'	=> 'text/html',
        			'content'	=> '<div class="contentcontainer"><div style="margin:0 auto">{{FDMbuttons}}</div>
        <div style="line-height: 30px">
        <ul style="list-style-type: none; list-style-image: none; list-style-position: outside; margin-left: 20px; font-weight: bold">
        	<li style="text-align: center; font-size: x-large; margin-bottom: 20px">[*tvpagetitle*]</li>
        	<li>Real Name : [*tvname*]</li>
        	<li>In-game Name : [*tvingamename*]</li>
        	<li>Age : [*tvage*]</li>
        	<li>Country : [*tvcountry*]</li>
        	<li>Games I Play : [*tvgames*]</li>
        </ul>
        </div>
        <hr />
        <div style="line-height: 30px">
        <h2>My Story</h2>
        [*tvaboutme*]
        </div>
        <hr />
        <div style="margin-top: 20px">
        [*tvcontent*]
        </div>
        </div>
        <div style="background-color:#444444; min-height:200px">
        [!MaxiGallery? &admin_webusers=`[[galleryowner]]` &display=`embedded` &disable_js_libs=`0` &embedtype=`smoothgallery` &smoothgallery_width=`640` &pics_per_row=`4` &max_thumb_size =`125` !]</div>',
        			'pagetitle'	=> 'ERR-Space',
        			'longtitle'	=> 'ERR-Space',
        			'published'	=> '1', //is the page published?
        			'parent'	=> $parent, //here we go create a doc in the first doc
        			'isfolder'	=> '0',
        			'template'	=> '4', //type template id here
        			'cacheable'	=> '0',
        			'createdby'	=> $wuid,
        			'createdon'	=> time(),
        			'editedon'	=> time(),
        			'publishedon'	=> time(),
        			'hidemenu'	=> '0',
        			'privateweb'	=> '1',
        		
        			);
        	
        	$modx->db->insert( $fields, $table_name); // put the fields in the db (id wil be created incremental.)
        //end of page creation
        
        /* grab the last inserted ID so we can set the document group and page id it belongs to*/
                $last_inserted_id = mysql_insert_id();
                $table_name = $modx->getFullTableName( 'document_groups' );
                $fields = array(
                                'document_group'   =>  '2',
                                'document'    => $last_inserted_id,
                                );
                $modx->db->insert( $fields, $table_name);
        
           return;
        }
          Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
          AugmentBLU - MODX Partner

          BLUcart - MODX Revolution E-Commerce & Shopping Cart
          • 7455
          • 2,204 Posts
          remove the last , in this line:
          ’document’ => $last_inserted_id,
          to look like this: ’document’ => $last_inserted_id

          that should do the trick
            follow me on twitter: @dimmy01
            • 7455
            • 2,204 Posts
            use this instead:
            /* grab the last inserted ID so we can set the document group and page id it belongs to*/
                    $last_inserted_id = mysql_insert_id();
                    $table_name = $modx->getFullTableName( 'document_groups' );
                    $fields2 = array(
                                    'document_group'        =>  '2',
                                    'document'              => $last_inserted_id
                                    );
                    $modx->db->insert($fields2, $table_name);
               return;
            }
            


            otherwise the array $fields will have parts that does not belong to that table (getting also alle the parameters from the document creation)
              follow me on twitter: @dimmy01
              • 12684
              • 118 Posts
              I have two questions on using this.

              How can you have the Users name on the documents pagetitle.

              Something like...
              'pagetitle'	=> '($wuid) s page',



              Also, what if you want these documents to be public. How can you have it automatically show public links to these pages, or what would be the best way to pull content from these pages to place on the Users profile page. The latter would be the best thing.
                • 25551 ☆ A M B ☆
                • 1,231 Posts
                For some reason i’m receiving the follow error and I have no idea what it is. It’s not showing up in the event log either.

                « MODx Parse Error »
                MODx encountered the following error while attempting to parse the requested resource:
                « PHP Parse Error »

                PHP error debug
                Error: mysql_num_rows(): supplied argument is not a valid MySQL result resource
                Error type/ Nr.: Warning - 2
                File: /home/sites/err-clan.com/public_html/manager/processors/cache_sync.class.processor.php
                Line: 103
                Line 103 source: $limit_tmp = mysql_num_rows($rs);

                Parser timing
                MySQL: 0.6889 s (26 Requests)
                PHP: 4.7097 s
                Total: 5.3986 s
                Error while inserting event log into database.
                  Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
                  AugmentBLU - MODX Partner

                  BLUcart - MODX Revolution E-Commerce & Shopping Cart
                  • 7455
                  • 2,204 Posts
                  maybe you db is broken try repairing / optimising your tables in phpmyadmin
                    follow me on twitter: @dimmy01
                    • 25551 ☆ A M B ☆
                    • 1,231 Posts
                    Ok I’ve repaired and optimised my tables and everything completed fine but the error remains... What other reason could cause this? I’m at work all day long but if you have time you’re still setup with admin on the site.

                    Thanks a lot!
                      Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
                      AugmentBLU - MODX Partner

                      BLUcart - MODX Revolution E-Commerce & Shopping Cart
                      • 12684
                      • 118 Posts
                      Dimmy,

                      Is there any chance you may know of a solution to the questions I posted earlier? Thank you.