Jump to:

7937 Posts in 1537 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Testimonials page number and limit

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 1207 Views
  • stevanovich
    Avatar
    Community Member
    60 Posts

    Testimonials page number and limit Link to this post

    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

  • fiord
    Avatar
    Community Member
    79 Posts

    Re: Testimonials page number and limit Link to this post

    hi Stevanovich
    You solved the problem?

    1207 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.