We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum
Pass a variable between layouts?
Is there a way to set a variable in a
perch_layout and use it in another
My page template has two layouts:
perch_layout('global/head') I've set a variable called
echo the variable in
perch_layout('global/head'); and it works.
echo it in
Looking at the docs, it looks like I need to pass a variable into
I was hoping this would work,
perch_layout('global/footer', [ 'lang'=> $lang, ]);
Inside the footer I'm using this:
It works if I hardcode the value, like this:
perch_layout('global/footer', [ 'lang'=> 'en', ]);
Or, if I move the code used to set the variable out of
perch_layout('global/head') and place it at the top of my page template.
This isn't ideal, as I'd like to use the variable in other templates. Is there a way to do this?
Perch Runway: 3.1.1, PHP: 7.1.12, MySQL: mysqlnd 5.0.12-dev - 20150407 - $Id: b396954eeb2d1d9ed7902b8bae237b287f21ad9e $, with PDO Server OS: Darwin, cgi-fcgi Installed apps: content (3.1.1), assets (3.1.1), categories (3.1.1) App runtimes: <?php $apps_list = [ ]; PERCH_LOGINPATH: /perch PERCH_PATH: /Users/stephen/Repositories/project/cms/perch PERCH_CORE: /Users/stephen/Repositories/project/cms/perch/core PERCH_RESFILEPATH: /Users/stephen/Repositories/project/cms/perch/resources Image manipulation: GD PHP limits: Max upload 32M, Max POST 32M, Memory: 128M, Total max file upload: 32M F1: 3b606135b33e6a102526838f4152a807 Resource folder writeable: Yes SCRIPT_NAME: /perch/core/settings/diagnostics/index.php REQUEST_URI: /perch/core/settings/diagnostics/ DOCUMENT_ROOT: /Users/stephen/Repositories/project/cms HTTP_HOST: project.local
Want to reply to this thread?Login with Perch