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.