We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 50860
    • 4 Posts
    Hi all, brand new modx user here, trying to get my head around the concept of resources and pages. So this is what I'm trying to achieve: Have a resource aka some content to appear on one page of my site as main content while on other pages as right column content, or perhaps on other pages just I'd have just title and summary.

    I'm not asking for detailed step by step guidance necessarily, but rather for guidance how to achieve this with modx. Thanks for all pointers!
    • That is what getResources is for. You tell the getResources snippet what resources you want to use, and a chunk to use for a template (we call these mini-templates "tpls" so they don't get confused with the main site templates), and in that chunk tpl you have the HTML structure for the block you want, using placeholder tags instead of the resource field tags. For example, for just title and summary, your tpl might look like this:
      <li>
      <h2>[[+pagetitle]]</h2>
      <p>[[+introtext]]</p>
      </li> 


      getResources will loop over all of the resources you told it to fetch (usually specifying a parent resource from which to fetch all of its children) applying this tpl to each one. So the placeholder [[+...]] applies to the resource that getResources is processing, while the resource tags [[*...]] will ALWAYS apply to the the current resource, i.e. the one with the getResources snippet on it. If you put [[*pagetitle]] in the chunk tpl, it would be the same for all of the listed items - the page title of the current resource.
        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
      • Another option, if you only want to show a given field from a single other resource, is the FastField add-on. That gives you a new MODX tag, [[#...]], that lets you specify a resource ID and the field you want to get from it:
        [[#42.content]]
        [ed. note: sottwell last edited this post 8 years, 8 months ago.]
          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
          • 36816
          • 109 Posts
          Susan beat me to it. In the couple of minutes it took for me to login and to type out a reply, she'd already posted about FastField (you have to move fast to get in before Susan 'round here).

          I second her suggestion.
          • I'm spending a lot of my time over on the Slack channel these days, so the forums don't get as much attention as they used to. http://modx.org/
              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
              • 50860
              • 4 Posts
              Hey, thanks to both of you! Pretty fast answers here! Both approaches sound quite promising, I will give it a try.
              • Check out pdoTools as well. It can be downloaded through the common installer within MODX.