doolak Posted June 2, 2013 Share Posted June 2, 2013 Hi there, as the title says I am trying to check the pageNum of a parent page - something like: $page->parent->pageNum (wich does not work) Any idea if and how one could do this? Cheers, Christian Link to comment Share on other sites More sharing options...
horst Posted June 2, 2013 Share Posted June 2, 2013 what is pageNum ? If you mean the count of subpages a page has, it is: $page->parent->numChildren Link to comment Share on other sites More sharing options...
doolak Posted June 2, 2013 Author Share Posted June 2, 2013 No, it is something different than numChildren. pageNum displays the current page number if you are using pagination. Link to comment Share on other sites More sharing options...
adrian Posted June 2, 2013 Share Posted June 2, 2013 I am not sure how a parent page can have a current page number. $page->pageNum will get you the page number of the current page. Perhaps you want the number of pages that would be generated when rendering the parent of the current page? Can you explain your structure and needs in a little more detail? Link to comment Share on other sites More sharing options...
doolak Posted June 2, 2013 Author Share Posted June 2, 2013 The problem is as follows: There are lots of galleries, on every page there are just 12 displayed (with pagination). If someone was visiting e.g. page 4 of the paginated gallery pages and chooses one gallery to view - he should have the option to go back to the gallery overview, but to page 4 of this, not to the first page. E.g.: The visitor was on http://www.xyz.de/galerie/page3 and watched one of the shown galleries When klicking "back to the overview" he should get back to http://www.xyz.de/galerie/page3 - not to http://www.xyz.de/galerie/ Link to comment Share on other sites More sharing options...
adrian Posted June 2, 2013 Share Posted June 2, 2013 Makes sense. So you need to somehow capture the page number the users comes from. Not sure how your are linking the user to watch a gallery, but you could append the page number as a GET variable to the link to the gallery so that the back to the overview link includes the page number. Does that sound ok? Link to comment Share on other sites More sharing options...
slkwrm Posted June 2, 2013 Share Posted June 2, 2013 @doolak You may try this. I took my code and modified it a little so it may not work out of the box. //parent of your galaries $galleryHome = $page->parent; //all your published gallery pages (make sure you use the same sort option as in your template when output) $galleries = $galleryHome->children; //page being viewed $currentPage = $page; //number of galleries per page $galleriesPerPage = 5; //index of the page in array $PageIdInArray=NULL; //the number of the page your current gallery belongs $pageNum=0; foreach($galleries as $i => $p) { //iterate every galleriesPerPage time if (($i%$galleriesPerPage)==0) { $pageNum++; } // if ($currentPage->id == $p->id) { $PageIdInArray = $i; break; } } //if we found our page in array and $pageNum<>0 if ($PageIdInArray && $pageNum) { //construct url to the galleris landing page $url = $galleryHome->url . "page" . $pageNum; echo "<a url='$url'>Back to galleries</a>"; } 3 Link to comment Share on other sites More sharing options...
adrian Posted June 2, 2013 Share Posted June 2, 2013 That would do it too Link to comment Share on other sites More sharing options...
horst Posted June 2, 2013 Share Posted June 2, 2013 Why not use on every overview-page: $session->set('lastOverviewPage', $page->url); and on every gallery page: echo '<a href="' . $session->get('lastOverviewPage') . '">go back to overview</a>'; ? 2 Link to comment Share on other sites More sharing options...
Can Posted August 5, 2014 Share Posted August 5, 2014 Why not use on every overview-page: $session->set('lastOverviewPage', $page->url); and on every gallery page: echo '<a href="' . $session->get('lastOverviewPage') . '">go back to overview</a>'; ? It can work and is clean and simple. But it's not working if the user enters directly the image and not the gallery. Thank you slkwrm! url should href of course but thank you anyways it's working like a charm! EDIT: so echo "<a url='$url'>Back to galleries</a>"; should be echo "<a href='$url'>Back to galleries</a>"; 1 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