Forum

Thread tagged as: Question

Special ID value for referring page's title?

In a 2-page list and detail setup, I'd like to be able to refer to the title of the page the content came from from within the detail template.

The purpose would be to supply a breadcrumb-like trail, or a "back to..." button with label.

For example, I can create the "back" button using the _page special ID like this:

<a href="<perch:content id="_page" type="hidden" />">Back</a>

What I'd like is something like this:

<a href="<perch:content id="_page" type="hidden" />">Back to <perch:content id="_page_title" type="hidden" /></a>

Is this possible?

Richard Terrick

Richard Terrick 3 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

I think we looked at this and it was too expensive to do for every request on the off-chance that it gets used. Instead, you'll need to just look it up and you need it.

Thanks Drew –

When you say "look it up as you need it", are you referring to this type of approach?

Drew McLellan

Drew McLellan 2638 points
Perch Support

You can use perch_page_attribute() to get the page title. I think you should have _page_id in the result set, which you can use to prime perch_page_attribute() to get information about the right page.

perch_page_attribute('pageTitle', [
    '_id' => 123, // your page ID
]);

Okay, that's a step closer – is it possible to populate the '_id' value without having to hardcode it?

The reason being is the "detail" page that I am using can show the detail view from any number of referring pages.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, absolutely. It should be _page_id in your result set.