We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29861
    • 59 Posts
    Hello,

    I have a chunk named ’mobileNav’ that I used with getResources to build a menu:
    <li>[[+pagetitle]]</li>

    Well, I’d like to add one or two lines in the menu. What’s the best way to apply the ’mobileNav’ chunk to resource number 13 huh
    Something like [[$mobileNav? &pagetitle=`13:pagetitle`]]? I guess not grin

    Any help around?

    Thank you!
    • I’m not sure what you’re trying to do, but have you tried the If addon?

      [[If? &subject=`[[+id]]` &operator=`is` &operand=`13` &then`[[$YourChunk]]` &else=`<li>[[+pagetitle]]</li>`]]


      You could probably use an output filter, too. I don’t think all of them are documented. I’ve seen some cool new ways to do conditionals with output filters recently, but I haven’t tested them.
        Time is what keeps everything from happening all at once.
      • Do you mean how you use that chunk with the getResources snippet?

        Or do you want to parse the chunk for that specific resource, outside of your existing getresource snippet?

        There’s also the getField snippet which you could use to grab only one resource (put your snippet in the <li> tags).
          Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

          Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
          • 29861
          • 59 Posts
          I meant to use that chunk with just one predefine resource.
          I think the getField snippet should do it (I didn’t know it):
          [[$mobileNav? &pagetitle=`[[getField? &docId=`13` &field=`pagetitle`]]`]]
          I’ll try it tomorrow smiley
          • I don’t think that there’s a getField for Revo. However, you’ll find a couple of versions of a getResourceField for Revo in the development forum. They have similar functionality and should do the trick.
              Time is what keeps everything from happening all at once.
              • 29861
              • 59 Posts
              I didn’t look at getResourceField snippet but I did my own (I always prefer looking for an existing Snippet in order not to redo what already exists).
              I called my snippet "ResField":
                $resource = $modx->getObject('modResource',$res);
                $value = $resource->get($field);
                return $value;

              and my calls are like that:
                  [[$mobileNav?
                     &pagetitle=`[[resField?res=`5`&field=`pagetitle`]]`
                     &alias=`[[resField?res=`5`&field=`alias`]]`
                  ]]

              It`s a little verbose but it works. I tried to do an output filter that would be like that: [[+5:resField=`pagetitle`]] but it did work.
              Thank for the insights smiley