Forum
How do I display just the title from each region on a page?
I have a page made up of several regions. How do I display a section navigation at the top of the page to link to the title of each region? i.e:
<div id="section-nav">
<a href="#Region1Title">Region1</a> | <a href="#Region2Title">Region2</a> | <a href="#Region3Title">Region3</a>
</div>
Since regions aren't dynamic, you'd just add your navigation by hand.
If you are generating regions dynamically with your own PHP, then you'd use the same logic to generate the navigation.
What about extracting an item from each region such as:
Could I do this from multiple regions, using perch_content_custom?
Yes you can, but you'll need to add the regions to the
perch_content_custom()
call by hand.How do I go about that? Sorry to keep asking questions but I have only just started learning the Perch lingo and finding perch_content_custom difficult to grasp.
Ah, sorry! I was thinking you were a different Mike Harrison.
If you want to aggregate content form multiple regions on the same page, it might be that the page structure needs rethinking. But that aside, you should be able to do it like so:
Your
section_heading.html
template would then include the common field from your regions:No worries Drew - I really need to change my name to something more unique! The code works great except that it pulls the headings from the regions in a strange order see below for example:
Is there a way I can use perch_content_custom to sort by region first, and then by heading?
Thanks, Mike.
You can't actually sort by region, no. Pulling content from multiple regions is the sort of thing we allow for, but the system was never really designed to work that way.
The thinking is that if you've put the regions in the page, you already know what they are.