Forum
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?
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?
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 primeperch_page_attribute()
to get information about the right page.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.
Yes, absolutely. It should be
_page_id
in your result set.