We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13577
    • 302 Posts
    This is an auto-generated support/comment thread for ListChildOrSibs.

    Use this forum to post any comments about this addition or any questions you have regarding its use.

    Brief Description:
    Show all child pages, or siblings if there are no children pages, with or without descriptions, in a list.
      Standard Disclaimer
      I could be totally wrong.
      • 28768
      • 3 Posts
      Is there another version/implementation of this that allows access to custom template variables, or could someone point me in the direction of hacking that in? It seems like it only pulls in the default ones. I’ve got a very faint idea of what needs to be changed from looking at the API info, but I’ve only been learning the system on and off for about two weeks now, and I’m not confident enough to start randomly messing with actual code just yet.

      Thanks in advance for any help.
      • Hacking snippets is not a big deal, it’s not like trying to hack the core. Just duplicate the original, rename your copy, and use that for your hacking. It’s a great way to learn how MODx works. Use one of the other snippets, such as Ditto, that does what you want as a model.
          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
          • 32669
          • 20 Posts
          Hi Jared,

          Excellent snippet but is there a way to only display the siblings even though one may have children documents?

          Thanks,

          Wouter
            • 13577
            • 302 Posts
            Not offhand no. The snippets intent was to show the children as the priority, and siblings if children didn’t exist. If you specify the children not to be in the menu, then you should get the desired effect, but I don’t know how that will affect other things you may have going on. Perhaps if you gave a few more details about what your scenario is...
              Standard Disclaimer
              I could be totally wrong.
              • 18355
              • 1 Posts
              I had several problems but only one deals with the code itself. (My browser doesn’t seem to handle the <span> tag very well. The description was right up against the link. I added
              tag just before the span tag to get the description to start on the next line. YMMV.)

              The one problem I consistently had was that the pagetitle was being displayed no matter what I set $linkTitle to. It appears that because I was on the parent page, I wasn’t hitting either condition in the if ($onCurrentPage){ section.

              My code was dropping right through and hitting
              $lcosOutput .= $children[$c]['pagetitle'];


              I changed that line to match the else condition, getting
              $lcosOutput .= ($children[$c][$linkTitle])? $children[$c][$linkTitle] : $children[$c]['pagetitle'] ;
              and it worked!

              I’m sorry if this is a kludge. I would love to learn how to clean it up or figure out why I’m not hitting the "else".

              Thanks for a WONDERFUL snippet!