Jump to content

Handling placeholder pages properly


RyanJ
 Share

Recommended Posts

Based on the structure below, "employee", "department" and "year" are simply place holder "pages". Each have been assigned a blank template and contain only a title field which is required. They serve no other purpose.

The issue I was seeing is that I could access these pages in the url directly. For example, root/location1/employee/ would simply display a blank page. This is undesirable for me as it made me fell empty :) and marking the page as hidden in the back-end did not resolve the issue. So I saw the option unpublished in the back-end and it works perfectly.

I then found Ryan's post here which explains a lot but this example I think deserves its own topic. Would my handling of this be considered advisable or would something else be a better solution, like a 301? I noted that marking a page hidden excludes it from the find() method, but I simply grabbed the children by their templates.

Location 1
  - Employee
     -- John Doe
     --Jane Doe

  - Department
    -- Confused Department
    --Even More Confused

   -Year
    -- 2013
    -- 2014

Link to comment
Share on other sites

One way I like to get around this problem is to have a 'list' template which just displays an unordered list of the page's children, like a menu, and use it for the parent pages (Employee, Department & Year). Then you can use breadcrumbs (good for usability) and it will allow an experienced visitor to navigate by editing the url if they so wish. I suspect it would also be helpful from an SEO and spidering perspective, but that's just a hunch.

Depending on your navigation and menu structure, those pages might never or rarely be seen, but, for the work involved, it can't hurt.

  • Like 1
Link to comment
Share on other sites

RJay,

In case you want to do a redirect to the first child, you could write something like this in your template:

// Check for children
if ($page->child->id) {
  $firstChild = $page->child;
  $session->redirect($firstChild->url);
}

// No child found...
throw new Wire404Exception();
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...