We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38723
    • 165 Posts
    Quote from: shyflower at Oct 22, 2014, 10:07 AM


    Quote from: BobRay at Oct 20, 2014, 05:19 PM
    If there's only one ID in each TV, you just need the number. If there's more than one, we need a whole new strategy. wink


    Okay, I think I need a whole new strategy.

    My blog has sections that are Home & Family (7), Writing (8) , Freelance(10), Enviro(24), Politics(25), and Reviewed(26). Each of those are the parent pages. Right now the only content in each parent page is the get resources to call its children into the content of the template. What I want to do is call the parent Page Title and its info text to the blank space so that when the blog post is from the home section, the blank space will describe the blog section, and the blank space will describe the writing section when the post is from that section.

    I could do it with text in a tv, but I thought that since the parent already has a page title and a space for infotext, it would be easier to do a template variable. Maybe not?
    My biggest concern about doing this right is that I don't mess up the php and lock myself out of the site, otherwise I would just give it a try.

    If I'm reading this correctly, you have several "collections" with "child" pages and on the child pages you wish to show the collection container's introtext/pagetitle?

    You could do this fairly easily using setPlaceholders

    Readme here: https://github.com/oo12/setPlaceholders

    So on the child page template you'd need to get the ultimate parent's introtext and pagetitle, so you could do:

    [[sph?
       &ph=`uparentTitle == Uparent.pagetitle ||
          uparentIntrotext == Uparent.introtext`
    ]]


    Then you could output them wherever in that template you'd like by using the placeholders you've set up, [[+uparentTitle]] and [[+uparentIntrotext]]
      • 27160
      • 50 Posts
      Doesn't work. I get a parse error. Unexpected ''

      Do I need to put the id numbers in the snippet array? If so, do I just separate them between the '' or do I need to do the apostrophies for each?
        Linda Jenkinson
        • 27160
        • 50 Posts
        Quote from: pdincubus at Oct 23, 2014, 02:18 AM


        If I'm reading this correctly, you have several "collections" with "child" pages and on the child pages you wish to show the collection container's introtext/pagetitle?

        You could do this fairly easily using setPlaceholders

        Readme here: https://github.com/oo12/setPlaceholders

        So on the child page template you'd need to get the ultimate parent's introtext and pagetitle, so you could do:

        [[sph?
           &ph=`uparentTitle == Uparent.pagetitle ||
              uparentIntrotext == Uparent.introtext`
        ]]


        Then you could output them wherever in that template you'd like by using the placeholders you've set up, [[+uparentTitle]] and [[+uparentIntrotext]]

        Not sure I am understanding this. I don't think these solutions will work because the section pages and the home page use the same template, the base template. The home page has the latest blog posts, so anything I put into the base template has to exclude the home page. That's one of the reasons why I wanted to use a template variable, so I could call only the section pages.

        Thanks both of you for your help, but I think I am just going to try another avenue. I'll just make chunks for that space and use a tv to call them.
          Linda Jenkinson
        • discuss.answer
          • 3749
          • 24,544 Posts
          My snippet will display nothing at all on any page that's at the site root, (like, presumably, the home page), because those resources have no parent.

          It would also be easy to modify the snippet to make it ignore other pages based on their IDs.
            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
            • 27160
            • 50 Posts
            Quote from: BobRay at Oct 23, 2014, 02:54 PM
            My snippet will display nothing at all on any page that's at the site root, (like, presumably, the home page), because those resources have no parent.

            It would also be easy to modify the snippet to make it ignore other pages based on their IDs.

            I tried what I wanted to do in just html on one page and I didn't like the way it looked, so I've gone a different route altogether.

            Thank you so much for all the work you did to help me with this. I've got the code in a notebook I keep for snippets and it may come in handy someday.
              Linda Jenkinson