We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17548
    • 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.

      • 3749
      • 24,544 Posts
      Try @DOCUMENT.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 17548
        • 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
            • 17548
            • 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
                • 17548
                • 74 Posts
                hence my original question smiley

                modx is quite fantastic, I am just not very bright
                • 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 smiley


                  Oh and another option would be using the getResourceField snippet.
                    Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                    Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                    • 2861
                    • 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 tongue
                        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.