Jump to content

Pagination issue


melissa_boyle
 Share

Recommended Posts

Hi guys,

I have worked with pagination multiple times but seem to be having major issues as it is not showing at all.

I have installed the module and selected page segments and allow page numbers within the template but still no joy.

My structure is as follows;

News

    Year

        Month

           Story

My code is as follows on the news page.

<?php
   $parent = $page->parent;
   $children = $page->children;
   $results = $page->find("template=news_story, limit=3, sort=-story_date");
   $pagination = $results->renderPager();
   
   ?>
<?php
   foreach ($results as $child) {
   
    echo "<article><div class='blog-media banner-blog'> ";
    foreach($child->story_image as $images) {
   $images1 = $images->size(628, 227);
   echo "<img class='news-img' src='$images1->url' alt='{$image->description}'>"; 
   }
    echo "<div class='tp-bannertimer tp-top'></div></div>";
    echo "<h4><a href='$child->url'>$child->story_title</a></h4>";
    echo "<ul class='no-bullet post-info'><li class='no-tag2'><i class='icon-clockalt-timealt'></i><span>$child->story_date</span></li></ul>";
    echo "$child->story";
    echo " <a href='$child->url' class='button small green'>Read More</a></article>";
    }
    ?>
<div class="pagination">
   <?php
      echo $pagination;
      ?>
</div>
 
Any help would be greatly appreciated.
Melissa
 
 
Link to comment
Share on other sites

Hi Melissa, 

I tried to reproduce this scenario on my local setup. It works for me. Here what I have done.

Here is my templates structure

└── news - Has templates/news.php file. Enable Allow Page Numbers (Templates > news > URLs Tab >  Checked Allow Page Numbers?)
    └── month - (Template > month Family Tab > Allowed templates for parents(s) - news, Allowed template(s) for children - news_story)
        └── news_story (Template > news_story Family Tab > Allowed templates for parents(s) - month
 
Here is my page structure
 
└── News (uses news template)
    └── 2014 (uses year template)
        ├── Feb (uses month template)
        │   ├── Story-4 (uses news_story template)
        │   └── Story-5 (uses news_story template)
        └── Jan
            ├── Story-1 (uses news_story template)
            ├── Story-2 (uses news_story template)
            └── Story-3 (uses news_story template)

I added fetching+pagination code in templates/news.php

<?php

if(!$page->template->allowPageNum) {
    // notify me to enable pagination in the template
    echo "<p class='alert label'>" .
        "This template needs page numbers enabled to support pagination!<br />" .
        "Go to: Admin - Setup - Templates - Edit: '$page->template' - URLs " .
        "</p>";
    exit;
}

$results = $page->find("template=news_story, limit=3");
$pagination = $results->renderPager();

?>
<?php foreach ($results as $child): ?>
    <?php echo "<h4><a href='{$child->url}'>{$child->title}</a></h4>";?>
<?php endforeach; ?>

<div class="pagination"><?php echo $pagination;?></div>

Hope this would help a little. Thanks

Edit: Fixed some typo 

  • Like 2
Link to comment
Share on other sites

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

×
×
  • Create New...