I have it working fine as per Ryan's docs but when I get to a page2 of results, my categories don't display. I should add that my categories are generated at the top of the page in their own loop.
The template also uses urlSegment to filter the results by category. I have added pagination to both the news template and also the categories template which get's called through urlSegment.
On the main news page, pagination works but the categories come up empty when on the 2nd page.
On the categories template, the pagination won't show at all, and I'm not sure why as it's pretty much an identical setup to the news template.
Here's all the code, in case any of you can make sense of it.... Thanks.
News index :
<?php include("./header.inc"); ?>
<div id="news_index" class="grey_gradient">
<?php if ($input->urlSegment1 !="") {
include ("./categories.php");
} else { ?>
<div id="news_top_bar">
<h5 id="news_header">Recent news items</h5>
<?php $news_cats = $pages->find("template=news_category");
if ($news_cats) { ?>
<ul id="news_cats">
<li>By category: </li>
<?php foreach ($news_cats as $cat) {
$numArticles = $pages->count("template=news_entry, news_category_link=$cat");
if ($numArticles > 0) {
?>
<li><a href="<?php echo $page->url . $cat->name; ?>"><?php echo $cat->title; ?></a> / </li>
<?php } ?>
<?php } ?>
</ul>
<?php } ?>
<div class="clear"></div><!-- /.clear -->
</div><!-- /#news_top_bar -->
<?php $news = $page->children("sort=-created, limit=3");
foreach ($news as $entry) {
$class = "news_box";
if ($entry == $news->last()) { $class .= " news_box_last"; } ?>
<div class="<?php echo $class; ?>">
<div class="news_index_text">
<h3><a href="<?php echo $entry->url; ?>"><?php echo $entry->title; ?></a></h3>
<h6><?php echo $entry->entry_date; ?> by <?php echo $entry->createdUser->first_name . " " . $entry->createdUser->last_name; ?></h6>
<?php if ($entry->summary) {
echo "<p>" . $entry->summary . "</p>";
} else {
$body_text = strip_tags($entry->body);
$text = substr($body_text, 0, 300);
echo "<p>$text...</p>";
} ?>
<a href="<?php echo $entry->url; ?>" class="button">Read on</a>
</div><!-- /.news_index_text -->
<?php if ($entry->main_image) {
$news_image = $entry->main_image->size(240,180); ?>
<img src="<?php echo $news_image->url; ?>" width="<?php echo $news_image->width; ?>" height="<?php echo $news_image->height; ?>" alt="<?php echo $entry->title; ?>" class="small_frame" />
<?php } ?>
<div class="clear"></div><!-- /.clear -->
</div><!-- /.news_box -->
<?php }
?>
<?php // PAGINATION LINKS
$pagination = $news->renderPager();
echo $pagination;
?>
<?php } ?>
</div><!-- /#news_index -->
<?php include("./footer.inc"); ?>Categories.php :
<?php
$name = $sanitizer->pageName($input->urlSegment1);
$category = $pages->find("template=news_category, name=$name");
$news_cats = $pages->find("template=news_category");
?>
<div id="news_top_bar">
<h5 id="news_header">Recent news items - <?php echo ucwords($name); ?></h5>
<?php if ($news_cats) { ?>
<ul id="news_cats">
<li>By category: </li>
<?php foreach ($news_cats as $cat) {
$numArticles = $pages->count("template=news_entry, news_category_link=$cat");
if ($numArticles > 0) {
?>
<li><a href="<?php echo $page->url . $cat->name; ?>"><?php echo $cat->title; ?></a> / </li>
<?php } ?>
<?php } ?>
</ul>
<?php } ?>
<div class="clear"></div><!-- /.clear -->
</div><!-- /#news_top_bar -->
<?php $news = $pages->find("template=news_entry, news_category_link=$category, limit=1");
foreach ($news as $entry) {
$class = "news_box";
if ($entry == $news->last()) { $class .= " news_box_last"; } ?>
<div class="<?php echo $class; ?>">
<div class="news_index_text">
<h3><a href="<?php echo $entry->url; ?>"><?php echo $entry->title; ?></a></h3>
<h6><?php echo $entry->entry_date; ?> by <?php echo $entry->createdUser->first_name . " " . $entry->createdUser->last_name; ?></h6>
<?php if ($entry->summary) {
echo "<p>" . $entry->summary . "</p>";
} else {
$body_text = strip_tags($entry->body);
$text = substr($body_text, 0, 300);
echo "<p>$text...</p>";
} ?>
<a href="<?php echo $entry->url; ?>" class="button">Read on</a>
</div><!-- /.news_index_text -->
<?php if ($entry->main_image) {
$news_image = $entry->main_image->size(240,180); ?>
<img src="<?php echo $news_image->url; ?>" width="<?php echo $news_image->width; ?>" height="<?php echo $news_image->height; ?>" alt="<?php echo $entry->title; ?>" class="small_frame" />
<?php } ?>
<div class="clear"></div><!-- /.clear -->
</div><!-- /.news_box -->
<?php }
?>
<?php // PAGINATION LINKS
$pagination = $news->renderPager();
echo $pagination;
?>I've just re-read part of the pagination docs here and have added "start=0, limit=n" to my news_index template so now categories are showing even on 2nd page. Still can't seem to get pagination showing on categories template though
Edited by Soma, 12 May 2012 - 02:22 PM.













