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"><< 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 >></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