Forum
Adding Meta to a Details page
Hi,
I've followed this Solution to set up a List with Details page: https://solutions.grabaperch.com/architecture/how-do-i-create-list-detail-pages
Now I'm a little stumped to how to set up the meta title and description for the details pages.
I'm using a layout var in my global.above to give me the option of using the page attributes or meta with perch custom :
<title><?php perch_layout_var('title'); ?></title>
<?php
if (perch_layout_var('meta', true)) {
echo perch_layout_var('meta', true);
}
?>
<?php if (perch_layout_var('page_att', true)) {
echo perch_page_attributes();
}
?>
Then in the template of my details page I have tried the following to return the id of 'short-headline' as the title from the template 'case-study-content.html', and get the meta from another template:
<?php perch_layout('global.above', array(
'title' => perch_content_custom(array(
'template' => 'case-study-content.html',
'filter' => 'slug',
'match' => 'eq',
'value' => perch_get('short-headline'),
), true),
'meta' => perch_content_custom(array(
'template' => 'content_meta.html',
'filter' => 'slug',
'match' => 'eq',
'value' => perch_get('s'),
), true),
));
?>
I admit I'm not really sure what I'm doing here. Am I on the right track?
Is
short-headline
on your query string?No it's a text field, would I filter on that id then to return it?
The
perch_get()
function pulls a value from the query string on the URL, so that's not what you want here.Are you trying to get a single value from the region? You can use the
skip-template
option for that.Thanks Drew. I'm (hopefully) getting closer.
I have this, wanting to get the content from the id 'short-headline' which is on the /what-we-do.php page with the template case-study-content.html from within the Case Studies Region.
Try this:
That seems to return the first Region items 'short-headline' rather than the one needed for its Details page
Ok, then just add your filter:
If anyone has a similar question this is what I ended up with:
I duplicated the content I wanted into its own template