Forum
Perch Global Var
Hi All
Is there a way to set a global variable using PHP that can then be used in any template...
what i want to do is use <perch:if exists="" /> to display tab or accorian on mobile
the site has been built and full with content so its too late to change form perch_content to perch_content_custom
Any ideas?
Yes, use
PerchSystem::set_var()
Then the templates have already been evaluated and compiled to HTML, so no variables at runtime will affect them.
Hi Drew
Issue is when i do this
the variable does not appear when i use <perch:showall />
but i cant use perch_content_custom as the client needs to choose from 3 templates that all use blocks
As I said, the templates have already been evaluated and compiled to HTML, so no variables at runtime will affect them.
I'm not sure I follow.
perch_content_custom()
andperch_content()
will both render blocks.So to make the variable appear i need to use perch_content_custom()
but to use perch_content_custom() i then need perch_content_create()
issue i then have is a template needs to be specified when using perch_content_create() the user cant choose
That's no the case. Or at least, that's no supposed to be the case.
You can replace this:
with this:
Hi Drew
i just tried that so i have the following
But when i create a new page there is no region
Is this Perch or Runway?
runway
If you turn on debug and load the new page, what does it output?
I think the main issues are
0.1286 0.001 No matching content regions found. Check region name (content) and page path options.
0.1296 0.001 Template file not found: /var/www/landandwave/perch/templates/content/.html
Hi Drew any update on this?
is it a perch issue or am i just doing something that's not possible..
As yet, I can't see why that isn't working. Have you tried an isolated example? You obviously have a lot going on on that page.
Hi Drew
i just tried with a new template and a new page
And the same issue no region
Even tried without the header and footer and no luck
Ok, getting the same here.
Do this instead:
Hi Drew
That sort of works....
it now makes the region but i get duplicate content on the page
Sorry, my typo:
That worked perfectly
Thanks very much just saved my life :)