We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7455
    • 2,204 Posts
    you could use a snippet in that template that looks if the loggedin user is the same as the owner of the page by comparing the logedinuserid to the createdby id.

    if its not the loged in user than redirect to the home page or any other page. its simple to create.
    I could make it for you.

    maybe you could look in the database to see if all the values are ok there (like the template id) and see if you have the right id set.
    you can look by hovering the links of the template and you will see the id in the bottom of the page in the link.

    Dimmy
      follow me on twitter: @dimmy01
      • 25551 ☆ A M B ☆
      • 1,231 Posts
      Dimmy, if you could help me out with the snippet that would be excellent. I’m coming up with some great ideas for one of my sites to give users that extra bit control over their accounts. I’m sure I could help you out with a website or something in return. Thanks
        Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
        AugmentBLU - MODX Partner

        BLUcart - MODX Revolution E-Commerce & Shopping Cart
        • 7455
        • 2,204 Posts
        This is not tested but I think this should work:
        <?php
        if($_SESSION["usertype"] == "manager") {$manager = "1";}
        $wuid  = "-".$modx->getLoginUserID();
        $owner =  $modx->documentObject['createdby'];
        if($wuid == $owner || $manager == "1"){
        return;
        }else{
        $modx->sendRedirect($modx->makeUrl($modx->config['site_start']));
        }
          follow me on twitter: @dimmy01
          • 25551 ☆ A M B ☆
          • 1,231 Posts
          Excellent Dimmy, seems to work!


          I was going to put a ditto call in the basic content area so that the main page of the clients area would be a navigation page to the child documents. How could I tell ditto to use the current page as the parent folder?

          [!Ditto? &startID=`???` &dateFormat=`%b-%d-%Y %I:%M%p`!]

          Using the call above I don’t know what to use as the startID for documents that are auto generated. Would I have to manually tell each auto generated parent is the parent of the ditto folder as well?


          Also to expand the idea slightly, using the plugin you gave me, how could i generate a parent document and say 3 child documents in one go? I have the plugin working to create a parent doc so how could I generate 2 or 3 documents in one go?

          grin
            Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
            AugmentBLU - MODX Partner

            BLUcart - MODX Revolution E-Commerce & Shopping Cart
            • 7455
            • 2,204 Posts
            [!Ditto? &parents=`[*id*]` &dateFormat=`%b-%d-%Y %I:%M%p`!]
              follow me on twitter: @dimmy01
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Also, the id of the current page is the default if you don’t specify a startID or parents parameter.
                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
                • 7455
                • 2,204 Posts
                Quote from: rossco at Apr 29, 2008, 03:29 AM

                Also to expand the idea slightly, using the plugin you gave me, how could i generate a parent document and say 3 child documents in one go? I have the plugin working to create a parent doc so how could I generate 2 or 3 documents in one go?
                grin

                <?php //only for the nice colors (so do not copy this line!!! plugins do not use this tag!!!)
                if($mode=="new"){   
                $wuid = '-'.$userid;
                	$table_name = $modx->getFullTableName( 'site_content' );
                	$fields = array(
                                        'type'	=>  'document',
                			'contentType'	=> 'texthtml',
                			'pagetitle'	=> 'pagetitle',
                			'longtitle'	=> 'my longtitle goes here',
                			'published'	=> '1', //is the page published?
                			'parent'	=> '60', //what is the parent of this new page?
                			'isfolder'	=> '1', // lets make this a folder
                			'template'	=> '1', //type template id here
                			'cacheable'	=> '0',
                			'createdby'	=> $wuid,
                			'createdon'	=> time(),
                			'editedon'	=> time(),
                			'publishedon'	=> time(),
                			'hidemenu'	=> '1'
                			);
                	
                	$modx->db->insert( $fields, $table_name); // put the fields in the db (id wil be created incremental.)
                
                //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();
                
                //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'	=> 'texthtml',
                			'pagetitle'	=> 'pagetitle',
                			'longtitle'	=> 'my longtitle goes here',
                			'published'	=> '1', //is the page published?
                			'parent'	=> $parent, //here we go create a doc in the first doc
                			'isfolder'	=> '0',
                			'template'	=> '1', //type template id here
                			'cacheable'	=> '0',
                			'createdby'	=> $wuid,
                			'createdon'	=> time(),
                			'editedon'	=> time(),
                			'publishedon'	=> time(),
                			'hidemenu'	=> '1'
                			);
                	
                	$modx->db->insert( $fields, $table_name); // put the fields in the db (id wil be created incremental.)
                //end of page creation
                
                
                   return;
                }
                


                that should do it

                ok fixed some typo’s should work like this I think and again some things changed
                  follow me on twitter: @dimmy01
                  • 7455
                  • 2,204 Posts
                  Quote from: sottwell at Apr 29, 2008, 03:50 AM

                  Also, the id of the current page is the default if you don’t specify a startID or parents parameter.

                  yes thats tru also
                    follow me on twitter: @dimmy01
                    • 7455
                    • 2,204 Posts
                    oops I see some errors imn my code
                    sorry
                    ok fixed the typo’s
                      follow me on twitter: @dimmy01
                      • 25551 ☆ A M B ☆
                      • 1,231 Posts
                      For some reason when you leave the <php? in place it doesn’t work.

                      When deleted it works... well nearly.

                      The folder is created and in the parent (60) but the sub page was not created under the new folder, instead it was created out with the parent folder. Both documents were created, the parent folder was successfully created in the right place and the sub document was created but not in the intended "new" parent folder.

                      It’s looking like it’s nearly there and should work but just need to figure out the above problem.

                      Thanks to you all.
                        Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
                        AugmentBLU - MODX Partner

                        BLUcart - MODX Revolution E-Commerce & Shopping Cart