vennwest Posted May 15, 2014 Posted May 15, 2014 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
owzim Posted May 15, 2014 Posted May 15, 2014 either you modify the links while creating the menu, like in this approach: https://processwire.com/talk/topic/4261-parent-pages-and-their-behavior/ or you put this in the template which wraps the child pages: $session->redirect($page->children->first()->url); 4
kongondo Posted May 15, 2014 Posted May 15, 2014 (edited) 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 May 15, 2014 by kongondo 4
owzim Posted May 15, 2014 Posted May 15, 2014 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 =) 1
totoff Posted May 15, 2014 Posted May 15, 2014 https://processwire.com/talk/topic/15-how-do-i-create-a-page-that-redirects-to-its-first-child/?p=25 2
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now