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 there:

    I am just getting started with modx (beyond the basics of applying my custom templates to [*content*]. I am trying to display a left-nav menu for all pages in my site except blogs articles. I want blog articles to use ditto to display the most recent in place of a left-nav.

    I am more of an HTML/CSS person, not a PHP person, so if you could please tell me:

    a) if this is the right way to go about it and;

    b) why this doesn’t work.

    ok:
    I created a template variable called leftnav which contains the following:

    [+phx:if=`[[UltimateParent? &top=`2`]]`:is=`2`:then=`[[Ditto? &startID=`2` &summarize=`2` &total=`20` &commentschunk=`Comments` &tpl=`nl_sidebar` &showarch=`0` &truncLen=`100` &truncSplit=`0`]]`:else=` [!Wayfinder?startId=`[*id*]` &outerClass=`leftnav`!]`+]
    


    And it works, sort of. If I am on my blog page (id=2) I get the ditto block displaying my blog posts (still the default ones from the install). If I’m on any of my content pages (not id=2 and not ultimateparent=2) I get my wayfinder menu. However, when I’m on my blog subpages (child pages of id=2) I don’t get anything. I’m assuming I’m using ultimateparent incorrectly, but I’m not sure why.

    Any help would be most welcome.


    • I would use a simple Template Variable, with the default value being @INHERIT, and then edit it for the parent pages. It would even be easier to make two chunks, one with the Wayfinder call and one with the Ditto call, use these as the values of the relevant parent pages’ TV values.
        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
        • 17548
        • 74 Posts
        Interesting. I guess I really don’t understand template variables (yet) ’cause I didn’t understand any of that. I guess I’m thinking about it the wrong way.

        It seems so easy at first and then it goes all pear shaped embarrassed
        • Template variables took me a while to wrap my head around, but they proved well worth the trouble once I did.

          http://www.sottwell.com/how-template-variables-work.html
            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
            • 17548
            • 74 Posts
            Thank you. This is helpful. My biggest issue was not understanding that tvs are configurable at the instance level. I was trying to put all the logic in at the template level.

            I’ll see what I can do with this. Thanks again