Thread tagged as: Discussion

Tip: Redirect to first subpage

I've used this for my last few sites and thought I'd drop it here in case it helps someone else. Often, I'll have a page structure such as:

About (/about)
-- Our Team (/about/our-team)
-- Our Facilities (/about/our-facilities)
-- Our Mission (/about/our-mission)

In this case, /about doesn't necessarily need its own page, so I've created a master page to automatically redirect to the first subpage.


$firstSubPage = perch_pages_navigation([
  'from-path' => $_SERVER['REQUEST_URI'],
  'levels'    => 1,
  'template'  => 'get_first_subpage.html',
], true);
header('Location: https://'.$_SERVER['SERVER_NAME'].$firstSubPage);


<perch:if exists="perch_item_first"><perch:pages id="pagePath" /></perch:if>
Shane Lenzen

Shane Lenzen 18 points

  • 4 years ago

Fancy! Thanks Shane. I'll be using that.

Jonathan Elliman said:

Fancy! Thanks Shane. I'll be using that.

Nice! Happy it will help.

very cool!