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

Forum

Thread tagged as: Question

2 page list/detail setup - how to grab content for the when using layouts

I have a 2-page list/detail setup for a portfolio and want to grab the content from a text region (<perch:content id="client_name" type="text" label="Client name" />) and put it in the <title> tag. I'm using layouts for the header.

I've seen a similar question in the forums, but not one involving layout files. Is it possible?

MY HEADER FILE:

<!doctype html> <html class="no-js" lang="en" dir="ltr"> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title><?php perch_layout_var('title'); ?></title> <?php perch_page_attributes(); ?> </head> <body class="<?php perch_layout_var('class'); ?>">

MY DETAIL PAGE:

<?php include('../perch/runtime.php'); ?>

<?php perch_layout('header', array( 'title'=>'Work', 'class'=>'work', )); ?>

<?php $result = perch_content_custom('Work', array( 'page' => '/work/index.php', 'template' => 'work_detail.html', 'filter' => 'slug', 'match' => 'eq', 'value' => perch_get('s'), 'count' => 1, 'skip-template' => true, 'return-html' => true, )); ?>

<div class="row"> <div class="small-12 medium-3 medium-offset-9 columns workdetailheader prevnext"> <p> <?php PerchSystem::set_var('is_prev', true);

perch_content_custom('Work', array(
'page' => '/work/index.php',
'template'   => 'work_prevnext.html',
'filter'     => '_order',
'match'      => 'lt',
'value'      => $result[0]['_sortvalue'],
'sort'       => '_order',
'sort-order' => 'DESC',
'count'      => 1,

));

PerchSystem::set_var('is_prev', false);

perch_content_custom('Work', array( 'page' => '/work/index.php', 'template' => 'work_prevnext.html', 'filter' => '_order', 'match' => 'gt', 'value' => $result[0]['_sortvalue'], 'sort' => '_order', 'sort-order' => 'ASC', 'count' => 1, )); ?> </p> </div> </div>

<?php echo $result['html']; ?>

<?php perch_layout('footer'); ?>

Franz Neumann

Franz Neumann 0 points

  • 3 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

You can pass variables into layouts, so you would need to retrieve the value before calling the layout, store it as a variable then pass that into the layout.

https://docs.grabaperch.com/docs/layouts/variables/