Jays Posted March 13, 2017 Share Posted March 13, 2017 Hey hello, I started a new Project and also new in processwire. So therefore sorry, if I ask a silly question, but I haven't found the answer in the documentation and here yet. I want to great a Website in the following structure: Section 1 = page section 1-1 page section 1-1 page section 1-2 page section 1-3 page section 1-4 Section 2 = page section 2-1 page section 2-1 page section 2-2 page section 2-3 page section 2-4 Section 3 = page section 3-1 page section 3-1 page section 3-2 page section 3-3 page section 3-4 Section 4 = page section 4-1 page section 4-1 page section 4-2 page section 4-3 page section 4-4 And each section should have the structure like in a slider Show - to go right (for the next page) or go left (for the previous page). The order should be like I set it in the admin-area. In which way and with which parameters can I create such a navigation, or how I get the Informationen about the next or previouse page? It would be great to get some ideas! thanks, Jay Link to comment Share on other sites More sharing options...
Robin S Posted March 13, 2017 Share Posted March 13, 2017 Hi @Jays and welcome! If I understand right, in your example if you are on "page section 1-2" you want to have a "prev" link to "page section 1-1" and a "next" link to "page section 1-3". If so then the API methods $page->next() and $page->prev() are what you're looking for. Link to comment Share on other sites More sharing options...
Jays Posted March 13, 2017 Author Share Posted March 13, 2017 Hi Robin S, thanks for you anwser. I tried it, but it doesn't work like this... Next und Prev is moving on the Level Section 1 - Section 2 - Section 3 - Section 4... Over the Sections I have the "Home" entry... Link to comment Share on other sites More sharing options...
Robin S Posted March 13, 2017 Share Posted March 13, 2017 41 minutes ago, Jays said: Next und Prev is moving on the Level Section 1 - Section 2 - Section 3 - Section 4... Yes, it navigates between sibling pages, so you would use it when you are on a child page of Section 1, Section 2, etc. If you are on page Section 1 and you want to get the first child of that page you would use $page->child(). So if you want to navigate between levels as well as between siblings you would use some logic in your template to determine how you generate the navigation links. For example, check if $page has children and if so use $page->child(), otherwise use $page->next() - that sort of thing. Edit: I just noticed this... 3 hours ago, Jays said: Section 1 = page section 1-1 You can't have a page actually be another page (e.g. it's first child). Each page is an independent entity in the tree hierarchy. But you can have a page redirect to another page when it is viewed on the front-end. See $session->redirect(). 1 Link to comment Share on other sites More sharing options...
diogo Posted March 14, 2017 Share Posted March 14, 2017 To go a bit deeper in what Robin explained. When you are on the last page of a level, you want the first page of the next sibling of it's parent. For this to work, you have to be actually positioned on the child page, and not the parent — you can do that by redirecting to the first child when positioned on one of the parent pages. As for the next and prev links something like this should work to get the correct pages; $prev = $page->prev->id ? $page->prev : $page->parent->prev->child; $next = $page->next->id ? $page->next : $page->parent->next->child("sort=-sort"); 4 Link to comment Share on other sites More sharing options...
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