can the @DOCUMENT binding only be used within a TV?
here’s what i’m looking to do: have a resource "menu", which we’ll say has an id of 10. in the template i’d like to include this document in the navigation area. the manager user i would like to edit this menu will not have access to edit any elements (chunks, templates, snippets, tvs, etc), but would have permissions to edit resource #10
is there a way to call "@DOCUMENT 10" in just one place? like call it directly from within a template, or a chunk? or does it need to be created as a TV? and then maybe hide that tv from the non-admin manager users?
-
☆ A M B ☆
- 3,141 Posts
YOu can do this with a snippet as follows:
New Snippet, name it something like ’getContent’:
<?php
$doc = ($docID) ? $docID : 10; //Check if the &docID parameter is set, if not use 10 as default.
$docData = $modx->getDocument($doc, '*', 0); // This searches for unpublished documents with an ID of $doc. To search for published, change the 0 into a 1.
if (empty($docData)) { return 'Uh oh... document not found!'; }
return $docData['content'];
?>
Call in your template:
[tt][[getContent]][/tt] or [tt][[getContent? &docID=`13`]][/tt] to get the content.
-
☆ A M B ☆
- 24,524 Posts
You can also use a TV. TVs can be assigned to document groups just as resources can, so they would be hidden from a manager user not assigned to the associated manager user group.
You probably know this, but just in case: The Wayfinder snippet will create a menu for you and will update it automatically when new documents are created.
-
☆ A M B ☆
- 24,524 Posts
However, you could use Jot for this. Put a simple Jot snippet on a page just for this, with the minimum configuration to only allow Manager users to post. Minimize the form tpl to just have two input fields, one for the link text and the second for the URL. Have a simple comment tpl to make a list item with the link. Then where you want the menu to be displayed, use ul tags to enclose a Jot snippet with no form.
Your editor can go to this page (it can even be unpublished, since manager users can see unpublished pages) and add/edit the links to his heart’s content. I’ve even added an AJAX drag-and-drop script to such a page so the editor can reorganize his list, using the "parent" field in the table for the position, since it isn’t used for anything else now.
-
☆ A M B ☆
- 24,524 Posts
The only reason I mentioned the Jot option was because having users edit a page full of links could become a disaster, while filling out two fields in a form is much simpler.
i agree, but right now that "page full of links" is... 2 links, and i’m thinking maybe someday it might get up to 3, or maybe even 4. haha. it’s always so hard to explain exactly what you’re doing in a brief forum post. in this case, it really won’t be used, so being as "static" as possible is probably best.
as always, thanks for your advice everyone!
Quote from: slush at Jul 15, 2010, 08:05 AM
i agree, but right now that "page full of links" is... 2 links, and i’m thinking maybe someday it might get up to 3, or maybe even 4. haha. it’s always so hard to explain exactly what you’re doing in a brief forum post. in this case, it really won’t be used, so being as "static" as possible is probably best.
as always, thanks for your advice everyone!
In that case, I’d just have the users email me the link and link text and do it myself. I think it would take less of your time in the long run.
For a longer list, I’d create a form to submit for adding new links and link text.