Forum
How to test the contents of the special value perch_page_path?
I can use this special value in a template to show the path to the current page ... <perch:content id="perch_page_path" type="hidden" />. As expected this shows the text of (for example) /xxx/yyy/index.php on the page. However, I don't want to display the value, but want to test against its value/contents.
Is there a way I can test another field in the template against the content of that special value (and removing the '/index.php' part)?
Basically, I have a multiple item field and want to do something different in the template on one of the multiple-items, and only if the value in the field equals /xxx/yyy (in other words the contents of id="perch_page_path" with the /index.php stripped off it).
I have tried this ...
<perch:if id="link" value="{perch_page_path}" match="contains">
But it gives this error in page debug ...
Array
(
[type] => 2
[message] => preg_match(): Unknown modifier 'p'
[file] => /home/xxxxxx/public_html/dev/perch/core/lib/PerchTemplate.class.php
[line] => 1115
)
Graham
That looks like a bug - the slashes aren't being escaped correctly.
Aha. So, if the bug wasn't there, would my code be working? If so, I'll implement that minor modification to the site at a future date and make the new site live today for the customer.
I think so, yes.
Thanks. I’ll await the bug fix arriving sometime. Happy to test anything if it’s necessary.