We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46073
    • 65 Posts
    Hi, I'm trying to use a getResources call in the &then=`` section of an IF call but the tick marks `` within my getResources are interrupting the IF call (ending it prematurely). I can't break out he getResources call into a chunk because it uses the wrong &parents=`[[+id]]` if I do that.

    Any ideas?

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

      • 4172
      • 5,888 Posts
      do you want to show us your complete call?
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 46073
        • 65 Posts
        Quote from: Bruno17 at Apr 11, 2014, 06:16 PM
        do you want to show us your complete call?

        <span>
        [[!If?
        &subject=`[[+isfolder]]`
        &operator=`EQ`
        &operand=`1`
        &then=`
        <div>
        <input id="inner[[+parent]][[+idx]]" type="checkbox" name="inner[[+parent]][[+idx]]">
        <label for="inner[[+parent]][[+idx]]">[[+pagetitle]] - [[+idx]]</label>
        <div class="drop">
        [[!getResources? &parents=`[[+id]]` &limit=`0` &tpl=`sidebar-nav-dropdown.tpl` &includeContent=`1`]]
        </div>
        </li>
        </div>
        `
        &else=`<a href="[[~[[+id]]]]">[[+pagetitle]]</a>`
        ]]
        </span>
        


        That is the IF call I wish would work. As it stand there the getResource &parent=`[[+id]]` returns the results I need. If I break out that getResources call into a chunk then the &parent=`[[+id]]` returns the incorrect results.
        • I would do this the other way around. Have the getResources snippet, with a default for when no children are found.
          [[!getResources:default=`<a href="[[~[[+id]]]]">[[+pagetitle]]</a>`? &parents=`[[+id]]` &limit=`0` &tpl=`sidebar-nav-dropdown.tpl` &includeContent=`1`]]
            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
            • 46073
            • 65 Posts
            Quote from: sottwell at Apr 11, 2014, 06:40 PM
            I would do this the other way around. Have the getResources snippet, with a default for when no children are found.
            [[!getResources:default=`<a href="[[~[[+id]]]]">[[+pagetitle]]</a>`? &parents=`[[+id]]` &limit=`0` &tpl=`sidebar-nav-dropdown.tpl` &includeContent=`1`]]
            How does that call know if a resource is a parent or not?
            • It doesn't care. If there are no children, then it outputs the default.
                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
                • 46073
                • 65 Posts
                That removes all the <div> and <input> tags used in the IF call, it simply won't do. Is there a way to just have the getResources function within the IF call?
                • Ok, use a Property Set for the getResources snippet. Then your getResources snippet will just look like
                  [[!getResources@myPropertySet]]
                    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
                    • 4172
                    • 5,888 Posts
                    you can also try with two different chunks and conditional tpls
                    and, if there is no reason to call that uncached, call everything cached!

                    folderTpl:

                    <div>
                    <input id="inner[[+parent]][[+idx]]" type="checkbox" name="inner[[+parent]][[+idx]]">
                    <label for="inner[[+parent]][[+idx]]">[[+pagetitle]] - [[+idx]]</label>
                    <div class="drop">
                    [[getResources? &parents=`[[+id]]` &limit=`0` &tpl=`sidebar-nav-dropdown.tpl` &includeContent=`1`]]
                    </div>
                    </li>
                    </div>


                    nonefolderTpl:
                    <a href="[[~[[+id]]]]">[[+pagetitle]]</a>


                    and in your getResources - call:

                      &tplCondition=`isfolder`
                      &conditionalTpls=`{"1":"folderTpl","0":"nonefolderTpl"}`
                      &tpl=`nonefolderTpl`




                      -------------------------------

                      you can buy me a beer, if you like MIGX

                      http://webcmsolutions.de/migx.html

                      Thanks!
                      • 52024
                      • 15 Posts
                      Total noobie here. Not sure if I should be posting here, but will give it a try. I'd like to add an if statement re: getResources to decide whether or not to display a div that includes a getResources call. Here's my feeble attempt:

                      [[!If?
                      &getResources?& parents=`[[*books]]:notempty=`
                      &then=`
                      <h3>Editions</h3>
                      <article class="newBooks">
                      [[!getResources?
                      &parents=`[[*books]]`
                      &depth=`0`
                      . . .
                      ]]`
                      ]]


                      Using lastest version of Modx.
                      Please help with the syntax. Many thanks.