This tutorial will show you how to allow users to edit only nested pages, without allowing them access to those pages’ parents.
Scenario: You have a site running on MODx and have several users with varying levels of access. One section of your site has the following structure:
Root
|
-->Resources
|
-->Teachers
|
-->Classroom Notes
You would like to let your teachers edit the “Classroom Notes” page every day with all the things that have happened that day, but you don’t want them to have access to any other page on the site. In fact most of them are so devoid of technical skill you want all the other pages hidden from the tree view when they login so there is no confusion about which page they are supposed to edit.
So in the Security tab of your manager you create a user group called “teachers” and add all the teachers to this group. You next create a document group called “teacher pages” and add the “Classroom Notes” page to it. Every other page goes to a private “admins only” document group. (Use the Doc Manager module under the Modules tab to mass edit pages’ document group associations.) Finally, you link this document group with the “teachers” user group.
But now you have a problem. Log in as a teacher and you won’t be able to access the page. You will won’t be able to see any pages at all! That’s because the parent pages of “Classroom Notes” are private for admins only.
You could make both the “Resources” page and the “Teachers” page part of the “teachers” document group. Then teachers would be able to see and edit the “Classroom Notes” page, but they would also be able to edit the parent pages. This is not a good option, now they can see three pages instead of just the one you want them to edit.
What to do?
Solution: Enter the @DOCUMENT binding
First, create a template variable called [*importPageContent*]. Give it the caption “Import another pages content with @Document ##” and leave the input type as “text”. Be sure to leave the default value blank, and don’t forget to associate this template variable with the template used by the “Classroom Notes” page.
Second, edit the template used by the “Classroom Notes” page. Add your newly created template variable just below the [*#content*] tag.
Next, create a new document under the root of your site. Give this document the title “Classroom Notes Content” and un-check the “show in menu” box. Associate this page with the “teachers” user group and every other page in the site with the “admins only ” group. Take note of this document’s ID.
Finally, edit your original “Classroom Notes” page. Leave the content text box completely empty and instead insert “@DOCUMENT ##” into the importPageContent variable text box, where ## is equal to the document ID of “Classroom Notes Content” page.
There you go, now the “Classroom Notes” page pulls its content from the “Classroom Notes Content” page and your teachers can only ever see and edit this latter page.
Enjoy!