Using Layout Variables
These little differences can be managed with Layout Variables.
Our page uses a global top and bottom Layout. The top layout currently uses
perch_pages_title() to output the
<title> tag with the page title as set within Perch. What if we wanted to be able to set particular values for the page title instead? We could do that with a layout variable.
perch_pages_title() we can replace that with
perch_layout_var('title'). This will output the value of the title layout variable at this point.
So how do we set that? When we call our layout, we just need to pass in an array of the variables we want to use in the layout.
<?php perch_layout('global.top', array( 'title' => 'Hello World', )); ?>
If you refresh the page, you can see that the title has been set to “Hello World”.