Forum
Can't get Perch Variables to work
Hi,
So I've used Perch variables many times in the past with no issues, but I just can't get it to work for some reason...
My PHP
PerchSystem::set_var('count', '123');
perch_content('map description');
My Template (being used by 'map description')
<perch:content id="title" type="text" label="Title" />
<perch:content id="subtitle" type="text" label="Sub-title" />
<perch:content id="count" />
<perch:content id="text" type="textarea" label="Text" html="true" editor="ckeditor" />
I'm sure I'm doing something stupid, but the 'count' field keeps showing in the CMS and isn't displaying. - Perch: 3.1.3, PHP 7.0.15 (and tried with 7.1.1) - I know the variable is set (as echo PerchSystem::get_var('count'); works as it should) - I have tried having a type of text, hidden and no type at all on the field (none of which work) - It is definitely the right template being accessed (if I replace the field with '123' manually, I can see it on the page) - I have used perch:showall (doesn't seem to offer any help or show the field 'count' at all)
Thanks for any help - I'm hoping this isn't a systemic bug with the current version and that I've done something wrong...
Hello Matthew,
You need to use
perch_content_custom()
:https://docs.grabaperch.com/templates/passing-variables-into-templates/
Thanks Hussein Al Hammad - I foolishly missed this and ended up reading about it on another forum after posting my original question.
Thanks for the help though!