Forum
Title and meta tags for list/detail setup
Hi, I'm using Layout Variables and Page Attributes to add editable unique titles and meta tags for each page of a site. However, where I've used a list/detail setup I am stuck on how to create editor editable titles and meta descriptions for the detail pages. I've seen a similar thread https://forum.grabaperch.com/forum/08-15-2015-page-details-and-metatags but I'm still a bit lost.
My global.top.php at the moment:
<title><?php perch_layout_var('title'); ?></title>
<?php
perch_page_attributes(array(
'template' => 'seo.html'
));
?>
For list/detail setup I'd like the title from portfolio-item.html template
<h1><perch:content id="title" type="text" label="Title" required="true" title="true" /></h1>
output as
<title>Title of the Detail Page</title>
Any help on this and also how to allow editors to add meta descriptions etc. for a list/detail setup whilst using Layouts much appreciated.
Create a template for your meta fields
Copy the fields also into your list/detail master template, adding the
suppress="true"
attribute so that they don't output on the page.In the head of your document, display the detail mode just as you do in the body, but this time set the template to be your new meta template.
Thanks Drew. With your help I've now set up editable titles and meta tags for detail pages.
My detail.php has this in the head
The rest of the site pages use global.top.php Layout, currently:
Ideally though I'd like to use my global.top.php Layout for list/detail parts of the site too. How would I go about this?
You should be able to pass the result into the layout using layout variables.
https://docs.grabaperch.com/docs/layouts/variables/
If it helps anyone, I am using this:
projects.php
header.php
If an override exists, output that - otherwise fall back to
perch_pages_title()
. Same can be done for any number of fields/meta/etc.