Forum

Thread tagged as: Question

Perch Layout Variables Question

I have a PHP include that I use for each Perch Page as follows:

<?php include($_SERVER['DOCUMENT_ROOT'].'/perch/runtime.php');?>
<?php header('Last-modified: . the_modified_date()');?>
<?php PerchSystem::set_var('heading2','Business Function');?>
<?php PerchSystem::set_var('heading3',perch_pages_title(true));?>
<?php perch_layout('global.header',array('business_name'=>' ‐ Business Name'));?>

which is referenced by another page:

<?php include('_global/global.inc');?>
<?php perch_layout('global.header',array('title_trailer'=>' ‐ Title Trailer'));?>
<?php perch_content_create('sidebar_content',array('template'=>'_sidebar_content.html'));?>

that has perch_content_create() statements however the perch_layout variable I have defined in the second page does not append to the first but rather it replaces the text so is there something I am doing wrong or do layout variables all need to be defined at once, e.g. as per:

https://docs.grabaperch.com/functions/layouts/perch-layout-var/

I tried changing global.header to global.header1 to no avail.

Thanks for any help

Garth Holmes

Garth Holmes 0 points

  • 4 years ago

Layouts have different scope so you have to pass variables into layouts on the perch_layout() tag.

Drew McLellan

Drew McLellan 2638 points
Perch Support

You're outputting two versions of the global header - is that your intention?