Forum

Thread tagged as: Problem

perch_pages_title not updating after set_page

I am trying to use perch_pages_title() to get the title of the current page

I am using set_page to define my pages as i have a single page app which i wish to provide some breakdown in the designer for the content editors

after calls to set page perch_page_url is correctly returning the url of the current page but perch_pages_title seems to return the same value on multiple calls and is cached as whichever page it is called on first, so for example

Imagine i have 4 pages

Homepage About (title About) Projects (title Projects) Contact (title Contact)

<?php PerchSystem::set_page('#About'); ?> 
<?php perch_pages_title(); ?> -- i would expect About -- actual About :)
<?php PerchSystem::set_page('#Projects'); ?>
<?php perch_pages_title(); ?> -- i would expect Projects -- actual About :(
<?php PerchSystem::set_page('#Contact'); ?>
<?php perch_pages_title(); ?> -- i would expect Contact -- actual About :(

and

<?php PerchSystem::set_page('#About'); ?> 
<?php PerchSystem::set_page('#Projects'); ?>
<?php perch_pages_title(); ?> -- i would expect Projects -- actual Projects :(
<?php PerchSystem::set_page('#Contact'); ?>
<?php perch_pages_title(); ?> -- i would expect Contact -- actual Projects :(

Thanks in advance for help

Edward Sparkes

Edward Sparkes 0 points

  • 5 years ago

Appreciate this has already been raised here https://forum.grabaperch.com/forum/08-21-2015-2813-perch-pages-title-returns-same-title-after-perchsystemset-page

but there was no clear indication if this was even considered a defect or as designed nor any indication of whether it could be fixed. For now i will have to add an extra text content to each page called page-title but it just seems a shame given there is already a page title attribute.

Perhaps could be fixed as part of Perch 2.9 "Fix all the things" :)

Many thanks, Ed

Drew McLellan

Drew McLellan 2638 points
Perch Support

We'll take a look at it, thanks.