So I have different blocks of HTML broken up into different templates that get embedded into one master layout template.
for example, a typical inner page template :
{embed="block/.html_header"}
{embed="block/.header"}
<div id="content">
{exp:channel:entries channel="pageContent"}
-- content here --
{/exp:channel:entries }
{embed="blocks/.sidebar" sbr_flt="right"}
</div>
{embed="blocks/.footer"}In the html_header template, I have some PHP that sets some variables depending on which page of the site you are on.
How do I pass the variables from html_header to other templates like the sidebar template or the footer template ???
Or in other words, how do I dynamically declare variables in one template that can then be available “globally” to all other templates ???
Thanks in advance for any and all help
Hi Brent,
I thought that you could only pass a variable through an embed tag - like you are doing with your “blocks” embed.
Embedded templates are parsed after the parent template, so maybe you could create your “global” variables in your parent template then you can pass it to any embedded templates you want.
Sometimes I’ve found that URL segment conditionals can be useful if your url structure relates to the content that should be shown on the page.
Sorry, it’s not much help… There have been many times when I wanted similar functionality, and had to do a work-around with segment variables or finding a way to pass the variable through an embed.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.