We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6705
    • 79 Posts
    Hi, I was wondering if anybody could maybe give me some clues/pointers to help with the following?

    There is a section of a website which I am developing which should have the following structure:

    1. The section home page, which includes a block of user-typed content (ie, the resource content of the page), and a non-user-editable block of content (which I assumed I’d include as a snippet in the template) consisting of
    (foreach child page within this section of the website):
    * an image for that child page,
    * the title of that child page,
    * the [~id~] of that child page (for making a link)
    * the 1st paragraph of that child page’s text (obtained from (how?) the resource content of that child page).

    2. The child pages within the section, each consisting of:
    * a block of user-typed content (ie, the resource content, as also noted above)
    * a number of blocks of non-user-editable content obtained from a database, specific to each page

    There is only one level of child pages, and there are about 10 child pages in total.

    What I’d like to do is have just one template for this section (or perhaps ’section home’ template, and ’section subpage’ templates if need be), and have the template work in such a way that the appropriate dynamic/database content can be handwaved magically into being.. wink

    I will need to write a snippet to bring in the database-driven content (which is not a problem), but I was wondering how I could have my snippet magically detect which page is actually calling it (eg, I guess passing the page ID into the snippet somehow - is that possible?), so that it can then assemble the appropriate database query parameters for each of the pages?

    Thanks for any advice.

    (I’m using MODx Evolution.)
      Please don't PM me unless it's absolutely essential: if a technical question is worth asking, it's worth asking in public, so that others can share their experience, and so that all can learn from the answers.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Sounds like a job for Ditto (or getResources, if you’re using Revo)
        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
        • 6705
        • 79 Posts
        Quote from: sottwell at Feb 03, 2011, 10:09 AM

        Sounds like a job for Ditto (or getResources, if you’re using Revo)

        Thanks. I can see now how Ditto could maybe work for including the first paragraph from each of the child pages into the section home page.

        Do you have any ideas, for the child pages themselves, about how I would convey the page-ID into my snippet call for retrieving the data I need from my database? I imagine MODx must make this available as a variable somewhere?
          Please don't PM me unless it's absolutely essential: if a technical question is worth asking, it's worth asking in public, so that others can share their experience, and so that all can learn from the answers.
          • 36416
          • 589 Posts
          Quote from: david55 at Feb 03, 2011, 10:31 AM

          Do you have any ideas, for the child pages themselves, about how I would convey the page-ID into my snippet call for retrieving the data I need from my database? I imagine MODx must make this available as a variable somewhere?

          Yes, inside your child template call your snippet with current ID parameter, example:
          [[DBSnippetName? &docid=`[*id*]`]]