Forum
Layout vars loading another perch_layout
I'm trying to load in different additional layout files using layout variables:
I have several css/js tags and code snippets I'd like to load for different pages. All stored in the layouts folder with different names.
I'd like to just specify which ones to load here:
perch_layout('global.footer', array(
'scripts' => 'scripts.contact'
));
I can retrieve one like so:
perch_layout('global.footer', array(
'scripts' => true
));
if (perch_layout_var('scripts', true)) {
perch_layout('scripts.contact');
}
But I want to specify which ones:
perch_layout('global.footer', array(
'scripts' => 'scripts.contact'
));
if (perch_layout_var('scripts', true)) {
perch_layout('(perch_layout_var('scripts', true)');
}
Any ideas please?
Can you get the content of the layout variable and use that?
Hi Alex,
Your code sets the $script variable but doesn't apply it to the include so nothing loaded, but I've managed to get it to work using your code with layouts, so thank you for pointing me in the right direction and solving the problem :o)
Here's the working code:
Code on the page:
Code in the global.footer layout file:
Thanks again
Or just:
That worked perfect too, of course!
Thanks Drew