We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16429
    • 254 Posts
    I needed to obtain pures document IDs to mark some items with a particular class in a Wayfinder menu, filtering by a TV.
    I decided to use the GetField snippet in the menu item template, but soon I discovered (never thought of it before) that Wayfinder doesn’t has a placeholder to simply output the ID number of listed documents.

    Fortunately it has a placeholder [+wf.id+] that outputs a id html attribute (id="XX", where XX is a number) based on the listed document ID but modified by Wayfinder, presumably to mantain it unique if there are more than 1 Wayfinder call per page.

    So I created a PHx modifier that extracts the ID number from the [+wf.id+] value.
    I called it phx:idifier

    <?php
    $output = str_replace("id=\"",'',$output);
    $output = str_replace("\"",'',$output);
    $output = ltrim($output);
    $output = substr($output, 1);
    return $output;
    ?>
    


    Now you can use output the listed document ID using [+phx:input=`[+wf.id+]`:idfier+] in Wayfinder templates where you can use the [+wf.id+] placeholder (read the documentation of Wayfinder to understand the previous passage).
    The outputted ID can be used in snippets parameters, in PHx, and basically everywhere you need the ID of the listed document!

    Attention!!! Test before using this method in a production environment.
      kudo
      www.kudolink.com - webdesign (surprised?)

      [img]http://www.kudolink.com/kudolinkcom.png[/img] [sup]proudly uses[/sup] [img]http://www.kudolink.com/modx.png[/img]
      • 15987
      • 786 Posts
      kudolink,

      there actually is a placeholder that outputs just the document id, it is [+wf.docid+]
        • 16429
        • 254 Posts
        Ooooooook. Perhaps I’ve to update my Wayfinder paper documentation and my brain before hitting the "New Topic" button.
        Do you think I can delete this topic?

        (I don’t even try to think of a full afternoon of work fighting with this thing tongue)
          kudo
          www.kudolink.com - webdesign (surprised?)

          [img]http://www.kudolink.com/kudolinkcom.png[/img] [sup]proudly uses[/sup] [img]http://www.kudolink.com/modx.png[/img]
          • 15987
          • 786 Posts
          just think of it as a learning experience tongue