Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

Testimonials page number and limit


Reply

2 Posts   1275 Views

Avatar
stevanovich

30 March 2010 at 9:31pm (Last edited: 31 March 2010 4:35am), Community Member, 60 Posts

Hi

I have a testimonials page up and running and want to limit the number on each page I see the in the CMS that it can limit the number to a page. Anyone any ideas to have to get pagination on the bottom and a number of articles limited?

Okay having trawled the forum site I found this but it doesn't work any reason why?

TestimonialPage.php

<?php
class TestimonialPage extends Page
{
   static $has_many = array (
      'Testimonials' => 'Testimonial'
   );
   
   public function getCMSFields()
   {
      $f = parent::getCMSFields();
      $f->addFieldToTab("Root.Content.Testimonials", new DataObjectManager(
         $this,
         'Testimonials',
         'Testimonial',
         array('Link' => 'Link','Author'=>'Author','Quote' => 'Quote'),
         'getCMSFields_forPopup'
      ));
      return $f;
      
      
   }

}

class TestimonialPage_Controller extends Page_Controller {
   
}
function Testimonials() {
if(!isset($_GET['start']) || !is_numeric($_GET['start']) || (int)$_GET['start'] < 1) $_GET['start'] = 0;
$SQL_start = (int)$_GET['start'];
$doSet = DataObject::get(
$callerClass = "Testimonial",
$filter = "`ParentID` = '".$this->ID."'",
$sort = "",
$join = "",
$limit = "{$SQL_start},4"
);

return $doSet ? $doSet : false;
}
?>

TestimonialPage.ss

<% if Testimonials %>
<ul>
<% control Testimonials %>
<li><a href="$Link">$Author </a><br>$Quote</li>
<% end_control %>
</ul>
<% end_if %>

<% if Testimonials.MoreThanOnePage %>
<p>
<% if Testimonials.PrevLink %>
<a href="$Testimonials.PrevLink">&lt;&lt; Prev</a> |
<% end_if %>

<% control Testimonials.Pages %>
<% if CurrentBool %>
<strong>$PageNum</strong>
<% else %>
<a href="$Link" title="Go to page $PageNum">$PageNum</a>
<% end_if %>
<% end_control %>

<% if Testimonials.NextLink %>
| <a href="$Testimonials.NextLink">Next &gt;&gt;</a>
<% end_if %>
</p>
<% end_if %>

The testimonials show but do ignore the pagination. The page number show up but don't work?

Any ideas?

Steve

Avatar
fiord

4 February 2011 at 11:45pm Community Member, 79 Posts

hi Stevanovich
You solved the problem?