Forum

Thread tagged as: Question, Problem

2 page list detail - How to get the id 'title' into the title tag in the header

Hi there

I have been reading through the forum, but still can't seem to get to grips with how to format perch_content_custom

I see that you advised someone looking to do the same this to use perch_content_custom so I hope I am on the right track

I have a 2 page list detail, and on the detail page , the detail returns fine using

<?php
          perch_content_custom('Team', array(
               'page' => '/about-us.php',
               'template' => 'team-detail.html',
               'filter'   => 'slug',
               'match'    => 'eq',
               'value'    => perch_get('s'),
               'count'    => 1,
          )); 
?>

What I want to do is take the person's name (which is the id="title" in the template of the name of the individual) and include it in the <title> in the header

I have tried all sorts of permutations and combinations including adding in the template with skip-template and raw, but I just get nothing at all - this is the sort of thing I have been trying to use, where the about-detail.php page is the detail page and 'title' is the id I want to return:


<?php perch_content_custom('title', array( 'page' => 'about-us-detail.php', )); ?>

the template for my content is this:


<div class="left"> <div class="teamleft"> <img src="<perch:content id="image" type="image" label="Biog Image" bucket="Team images" />" alt="<perch:content id="title" />" /> </div><!-- Image Div Ends --> <div class="teamright"> <h1><perch:content id="title" type="text" label="Name" required="true" title="true" /></h1> <h3 style="margin-top:0;"><perch:content id="role" type="text" label="Role" required="true" title="true" /></h3> <perch:content id="desc" type="textarea" label="Biography" textile="true" editor="markitup" /> <h3>Contact Details</h3> <p>T: <perch:content id="directphone" type="text" label="Direct Line" required="true" title="true" /> / M: <perch:content id="mobilephone" type="text" label="Mobile Number" required="true" title="true" /><br> <a href="mailto:<perch:content id="email" type="text" label="Email Address" required="true" title="true" />?subject=Email communication from www.voxmedia.co.uk"><perch:content id="email" type="text" label="Email Address" required="true" title="true" /></a></p> </div> </div> <perch:content id="slug" for="title" type="slug" suppress="true" /> <perch:content id="image" type="image" label="Biog Image" width="400" crop="true" suppress="true" />

I know this is probably pretty obvious, but I have been at it for an hour, read through the forum and am no closer to understanding it - can you point me in the right direction please?

cheers

ben

Ben Read

Ben Read 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Do this:

<?php
          perch_content_custom('Team', array(
               'page' => '/about-us.php',
               'template' => 'team-title.html',
               'filter'   => 'slug',
               'match'    => 'eq',
               'value'    => perch_get('s'),
               'count'    => 1,
          )); 
?>

With this:

<perch:content id="title" type="text" />

Ah, I see... it's the template - and of course it works!

https://voxmedia.co.uk/about-us-detail.php?s=tatum-cherrill

Thank you so much Drew!