Jump to content

How to show first child directly


gerald
 Share

Recommended Posts

Hi everybody, I have a main menu item with children. By clicking on the main menu item, automatically the first child should be displayed. How to solve this problem? If a similar question has already been answered - sorry, could´nt find it. Thanks very much.

Gerald, Austria

Link to comment
Share on other sites

Or if you are lazy like me...
 
This should work as well, I think...

$session->redirect($page->child()->url);

In some cases, can be a good idea to first check if page actually has children ...

if($page->numChildren) $session->redirect($page->child()->url)

Oh, and welcome to PW!

Edited: corrected code, etc...  :-)

Edited by kongondo
  • Like 4
Link to comment
Share on other sites

Or if you are lazy like me...

This should work as well, I think...

$session->redirect($page->child->url);

Oh, and welcome to PW!

Nice shortcut, did not know it existed. But I think it's less expressive =)

  • Like 1
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...