Marty Walker Posted October 19, 2011 Posted October 19, 2011 Hi, I'm use the code below to generate sub-navigation across some pages in my site. Each page uses the same template. As I click on each item in the list it generates the sort order is totally different each time. I've tried clearing the browser cache as well as clearing the PW cache to no effect. Stumped. Regards Marty <?php if($page->path != '/' && $page->rootParent->numChildren > 0) { echo "<ul class='subnav'>"; foreach($page->rootParent->children("sort=sort") as $child) { $class = $page === $child ? " class='current'" : ''; echo "<li$class><a href='{$child->url}'>{$child->title}</a></li>"; } echo "</ul>"; } ?>
Soma Posted October 19, 2011 Posted October 19, 2011 Not getting what exactly happens, are they random? Do you happen to have set a sorting in children tabs sort setting?
Marty Walker Posted October 19, 2011 Author Posted October 19, 2011 The last few nav items down the left side, when clicked, it seems to change the order of the list. I've left the sort in the admin blank (manual). As I understood it if I don't use a field it just uses the order it appears in the admin list. Regards Marty
Soma Posted October 19, 2011 Posted October 19, 2011 Sorry I can't spot any changed in the order when browsing thru your site... ? But maybe I'm still looking at the wrong. Normally you don't have to set sort selector if not custom order is set in children. Edit: Ah Now I've experienced what you telling on subnav left side. Edit: There's must be something else involved, cause I can't reproduce this using your code 1:1 on PW example Site.
Marty Walker Posted October 19, 2011 Author Posted October 19, 2011 Beats me. If use just that code in the template it works fine. If I include all my other code the order chops and changes. BUT if I put all my code into one file as opposed to using <?php include('file.inc'); it all works fine. Strangely that subnavigation part of my code isn't an include.
Soma Posted October 19, 2011 Posted October 19, 2011 I'm not sure anybody can help without seeing the whole code. I have various sites now with multiple includes with and without navigation code and I never experienced something like this.
Marty Walker Posted October 19, 2011 Author Posted October 19, 2011 This is my original setup with includes: http://pastie.org/2723342 and without: http://pastie.org/2723358 I'm going to sleep on this one. Regards Marty
Soma Posted October 19, 2011 Posted October 19, 2011 I tried your code with and without includes, but I still can't reproduce this. Sorry, but don't know what could produce this other than something in your install or settings on page level. It doesn't make sense, that it would work differently without than with includes. Maybe someone else got an idea.
ryan Posted October 19, 2011 Posted October 19, 2011 For the pages that are changing order, try re-ordering them in the PW admin (drag-drop). If these pages were ordered by something else at some point, they might not have an initial order established and could just be sorting at the whim of MySQL. If it changes with the includes, that makes me think there is something in one of the includes that is modifying the query behind-the-scenes. But I honestly think you'll be able to fix this one just by drag-and-drop. To make sure it re-sorts the whole list, drag some other page to the top and drop it there. Then drag it back to where it should be. I'm guessing things will start working after that?
Marty Walker Posted October 19, 2011 Author Posted October 19, 2011 Thanks Ryan that did the trick. I initially imported the pages via the Import Pages from CSV module. The About Us was the only part that didn't need reordering.
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