Jump to content

Recommended Posts

Posted

In one of my sections' news pages, paginated list of news items:

$results = $page->children("limit=3, sort=-date"); 
$pagination = $results->renderPager();
echo $pagination;
echo "<ul class='nav'>";
foreach($results as $result) {
    echo "<li><p><a href='{$result->url}'>{$result->title}</a><br /><span class='summary'>{$result->date}</span></p></li>";
}      
echo "</ul>";
echo $pagination; 

In the sidebar (from head.inc), list the latest 5 news items from that section:

$news = $page->rootParent->find("template=news-item, limit=5, sort=-date");
foreach ($news as $newsitem) {
echo "<li><a href='{$newsitem->url}'>{$newsitem->title}</a></li>";
echo "<span>{$newsitem->date}</span>";
}

On the first news page the sidebar displays correctly, when you go to page 2 I would expect the same five news items to be displayed. Instead the next five news items are displayed. Likewise for page 3, the next five news items are displayed. Why is this happening? ???

Posted

Try using a more defined selector.

$news = $pages->find("template=news-item, limit=5, sort=-date, parent=/newsparentpage/");

You might not even need the parent if the template is enough.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...