We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36537
    • 16 Posts
    Hello,
    I'm looking to add this piece of code to do the following:

    Basically if the page has subpages (children) then output code, if not don't output anything.

    [[If?
    &subject=`[[+?]]`
    &operator=`!empty`
    &then=`<div id="SUB_MENU"><h5>See Also...</h5>[[Wayfinder? &startId=`[[UltimateParent? &topLevel=`1`]]`&level=`1`]]</div>`
    &else=``
    ]]

    My issue is that I'm not sure what the subject call would be to check for children/ subpages?

    Could anyone help on this issue?

    Many Thanks
    Jordan

    This question has been answered by rx2. See the first response.

      Zooba Ltd - Web Design & Development, Wales UK
      • 36457 ☆ A M B ☆
      • 100 Posts
      I've been dumped for secs because I don't know what the [[+?]] stands for, and that was the problem you meant.
      I think this can be solved by using

      [[!getResources?&parents=`[[*id]]`&toPlaceholder=`subpages`]]
      
      [[+subpages:notempty=`<div id="SUB_MENU"><h5>See Also...</h5>[[Wayfinder? &startId=`[[UltimateParent? &topLevel=`1`]]`&level=`1`]]</div>`:else=`walabawoohoo`]]



      As you can see, you can use the output modifiers, which is MODX's strength, to accomplish the task without using If.
      The link can be found here.

      If it don't work (because I haven't tested it yet), you can also test this:
      [[!getResources?&parents=`[[*id]]`&toPlaceholder=`subpages`&tpl=`@INLINE [[+total:notempty=`<div id="SUB_MENU"><h5>See Also...</h5>[[Wayfinder? &startId=`[[UltimateParent? &topLevel=`1`]]`&level=`1`]]</div>`]]`]]
      To be safe, you can put @INLINE stuff into a chunk. I'm not sure about this.

      Good luck.
        • 36537
        • 16 Posts
        Hi Nepheus,
        Thanks for the reply. smiley

        Sorry for not being clear enough. Yes [[+?]] was identifying my issue.

        I've tried your first solution but this just outputted "walabawoohoo".

        Also gave the second solution a try (in chuck) but this didn't output nothing.

        I'll try and mess around with the first option. If you have any other ideas that would be greatly appreciated.

        Thanks again
        Jordan
          Zooba Ltd - Web Design & Development, Wales UK
        • discuss.answer
          • 25803 ☆ A M B ☆
          • 721 Posts
          Make sure the parent page has Container checked in the Settings tab:

          [[If?
          &subject=`[[*isfolder]]`
          &operator=`eq`
          &operand=`1`
          &then=`<div id="SUB_MENU"><h5>See Also...</h5>[[Wayfinder? &startId=`[[UltimateParent? &topLevel=`1`]]`&level=`1`]]</div>`
          ]]
          


          or

          [[[[*isfolder:is=`1`:then=`$yourchunk`]]]]
          


          Where $yourchunk (whatever name you give it) contains:

          <div id="SUB_MENU"><h5>See Also...</h5>[[Wayfinder? &startId=`[[UltimateParent? &topLevel=`1`]]`&level=`1`]]</div>
          


          Technically I think you only need to use a conditional statement to show: <h5>See Also...</h5> as the Wayfinder call won't show anyway children when there are no children so you could have something like this (untested):

          <div id="SUB_MENU">
          [[[[*isfolder:is=`1`:then=`$yourchunk`]]]]
          [[Wayfinder? &startId=`[[UltimateParent? &topLevel=`1`]]`&level=`1`]]
          </div>
          


          Where $yourchunk only contains <h5>See Also...</h5>.

          or

          <div id="SUB_MENU">
          [[If?
          &subject=`[[*isfolder]]`
          &operator=`eq`
          &operand=`1`
          &then=`<h5>See Also...</h5>`
          ]]
          [[Wayfinder? &startId=`[[UltimateParent? &topLevel=`1`]]`&level=`1`]]
          </div>
          




            • 36537
            • 16 Posts
            Hi Rx2,
            Thanks for your reply and help.

            The first option worked perfectly smiley

            Thanks again,
            Jordan
              Zooba Ltd - Web Design & Development, Wales UK
              • 36457 ☆ A M B ☆
              • 100 Posts
              Hi,

              The toPlaceholder option is only for getResources 1.6 and later (as it is documented like so), I'm sorry I didn't state it early.
              Rx's solution is just find by using the isfolder value of the resource, my solution is more practical by doing another query to get and check the result. I've tested with the first solution and it works fine. By the way, it's good for you to find out which is working. That's great.

              Cheers,
                • 46754
                • 3 Posts
                Thanks !!! That simple part [[[[*isfolder:is=`1`:then=`$yourchunk`]]]] did the trick for me too.
                Works perfectly now.