Jump to content

sort order results


Marty Walker
 Share

Recommended Posts

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>";
}
?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

  • 3 months later...

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...