Jump to content

Parent pages and their behavior.


owzim
 Share

Recommended Posts

Hi guys,
 
if you have your page tree structure, some of the pages with children act solely as a container. So some of the time, at least when I am structuring web sites the pages don't provide any content themselves.
 
On a regular web site I do these two types of pages are very common:

  • Type 1: Pages that list content, like news items, articles or images and then link to their respective full content view.
  • Type 2: Pages that contain full featured pages which are very individual in content so you don't want to list them on a landing page.

How do you treat those type 2 pages in your navigation?
 
I've been using two different methods:

  • They are not clickable, so there is no link associated with them
  • The link leads to their first child

I recently added these as options with radio buttons (with the Page Field, more on that) to my custom "options" tab I use on templates:
 
(●) links to first child
(  ) no link
 
So in my menu creation loop is use something like this ($currentPage being the current page within the loop):

<? if ($currentPage->numChildren > 0 && $currentPage->options->has("name=links_to_first_child")): ?>
    <li><a href="<?= $currentPage->children->first()->url ?>"><?= $currentPage->title ?></a></li> 
<? elseif ($currentPage->options->has("name=no_link")): ?>
    <li><a href="#"><?= $currentPage->title ?></a></li> 
<? else: ?>
    <li><?= $currentPage->title ?></li> 
<? endif ?> 

So, just wanted to share my method and ask how you go about it.

  • Like 1
Link to comment
Share on other sites

For pages that are only containers, I usually try to implement them as just a general listing page of the children so that there is something there if someone goes there. Basically, I like containers that behave as containers, listing what children they have. I also check the "hidden" box for the page, so that it stays out of navigation and searches, when desirable. Other strategies I've used are to: Not implement a template file, so the page throws a 404 when you access it; Have it redirect to either the first child, or it's immediate parent, or the homepage, using a $session->redirect(). 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...