Search the Community
Showing results for tags 'pagination'.
-
Hi guys, have been having an issue with pagination. It's a bit odd, 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
-
Hi, I am including pagination on my blog page, its not quite working. I have 5 test posts in total, showing the first 3 posts on the main blog page. You can navigate to page 2 for the remaining 2 posts which works ok, but i'm losing my 'info' and 'about' pages in the main navigation which are children of the home page. Also the pagination links are showing 6 pages, which are empty after page 2. (too many pagination links) Here is the link to the blog page with pagination links at the bottom: http://www.hoof.net.au/pwire/blog/ This is the pagination code in on my blog page template: <?php $results = $pages->find("id>1, limit=10, sort=date"); $pagination = $results->renderPager(); echo $pagination; ?> I tried a few things after reading the pagination info page which mostly resulted in no pagination links at all. regards, Alex