-
- 74 Posts
Hi:
I’m just ramping up on Modx Revolution and trying to minimize TV clutter for my clients (editors).
I know I can pull in the content of a resource from inside a TV with a [@RESOURCE #] reference. However, this syntax doesn’t work directly in the template.
What’s the proper syntax for that? Is it possible? I tried [[@RESOURCE #]] and other combinations, but none of them are working for me.
-
- 24,544 Posts
-
- 74 Posts
Thank you.
Unfortunately [[@DOCUMENT 11]] doesn’t display the content.
Running:
MODx Revolution 2.0.5-pl (traditional)
On hosted Linux Apache
No wrappers for the at-bindings at all. Just put @DOCUMENT or @FILE (etc.) inside the text or textarea inputs on the backend of the Manager.
Ryan Thrash, MODX Co-Founder
Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
-
- 74 Posts
Thanks Ryan, but I seem to be off track.
For context:
My site has a sidebar that will contain a vertical stack of hyperlinked images. While I’m sure there are different ways for me to implement this for my clients, who are not HTML savvy, I have decided that while I am learning modx the easiest thing for me to do is have the content of the sidebar be contained in a document resource, which they can conceptually understand as a reusable/included element.
Right now, my template contains a TV that references the document using @DOCUMENT 11
My original question was whether I could just do the reference from the template, rather than from the TV, because I want to remove the clutter of TVs from the editing experience.
When I do as you suggest, put @DOCUMENT 11 directly in my template, it just outputs as text.
You can’t put @DOCUMENT or any at-bindings in a template. They only work in TVs.
Ryan Thrash, MODX Co-Founder
Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
You can use a snippet like getResources to fetch a page’s content. Just set it’s template chunk to [[+content]] only. (Remember to call &includeContent=`1` also, as I don’t think it includes content by default without it)
You can also make your own snippet if you want, may save some resourced compared to the getResources snippet.
$docid = 999; // Put the ID of the resource with the sidebar content here
$resource = $modx->getObject('modDocument', $docid);
return $resource->getContent();
Untested, but should work
Oh and another option would be using the getResourceField snippet.
-
- 8 Posts
I think Mark means with getField the GetResourceField snippet. That´s my suggestion too, works for me.
Oops, yea. getField was for Evo