Jump to:

3460 Posts in 1064 Topics by 739 members

Data Model Questions

SilverStripe Forums » Data Model Questions » The method 'getviewer' does not exist on 'PaginatedList'

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

Page: 1
Go to End
Author Topic: 921 Views
  • merrick_sd
    Community Member
    95 Posts

    The method 'getviewer' does not exist on 'PaginatedList' Link to this post

    I want to be able to filter a paginated list based on passed params.
    eg filter buy Area, category ..etc

    if i go directly to the page i do not get an error.

    class EstateCategoryPage_Controller extends Page_Controller {
    static $allowed_actions = array(

    //do i need a routes.yml file
    public static $url_handlers = array(
        'property//$Action/$ID/$EstateCategoryPageID' => 'EstateItemList'

    function EstateItemList() {
       $Area = '%';
       $OfferStatus = 'FOR SALE';
       $ECatPageID = 30;
       /* test for retrival of QueryString
       $CatPageID = Controller::curr()->getRequest()->param('EstateCategoryPageID');
       //$CatPageID = $this->request->param('EstateCategoryPageID');
       //print query string
       //print_r($CatPageID); //yeap it works
        $buildfilter = EstateItem::get()->filter(array('Area:PartialMatch'=> $Area,'Active' => 1,'OfferStatus' => $OfferStatus));
        //fixes the page in pagination
        $PaginatedList = new PaginatedList($buildfilter,$this->request);
        return $PaginatedList;   

    //comment i'm not actually doing any filtering yet from the passed params..baby steps!

    }//end controller

    If i go to the page and call a function to pass query string i get an error

    eg: http://dev.mydomain.co.uk/property//EstateItemList/29/Offices/

    error : The method 'getviewer' does not exist on 'PaginatedList'

    i've looked at this ticket also

    and tried

    return $this->customise($PaginatedList)->renderWith('PropertyResults');

    error : The method 'getviewer' does not exist on 'DataList'

    return $this->customise($buildfilter)->renderWith('PropertyResults');

    error : The method 'getviewer' does not exist on 'DataList'

    // Please do not change the exception code number below.
    661          throw new Exception("Object->__call(): the method '$method' does not exist on '$this->class'", 2175);

    Line 661 in /home/hmyapp/public_html/framework/core/Object.php

  • Willr
    Forum Moderator
    5508 Posts

    Re: The method 'getviewer' does not exist on 'PaginatedList' Link to this post

    You're trying to render a list directly using /EstateItemList/ in the browser which rather than returning an HTML template you've got it returning a List.

    You should name your action and method *differently* or render the list into some template instead of returning it.

    static $allowed_actions = array(

    In your EstateCategoryPage_list.ss template then you would use <% loop EstateItemList %>

    Make sure in your template you don't simply chuck $EstateItemList in as SilverStripe knows it's a list but not how you want to display it. You need to use <% loop %> to iterate over it.

  • merrick_sd
    Community Member
    95 Posts

    Re: The method 'getviewer' does not exist on 'PaginatedList' Link to this post

    many thanks that worked.




    I have
    mysite > routes.yml
    Name: myroutes
    After: framework/routes#coreroutes
    'property//$Action/$EstateCategoryPageID/$Area/$OfferStatus': 'EstateCategoryPage_Controller'

    but this results in a error
    [User Warning] popCurrent called on ModelAsController controller, but it wasn't at the top of the stack

    basically i want to access more that the standard 2params of ID/OtherID
    how i can use more than 2 params

    for example: mydomain.com/mypage/myaction/PrmOne/PrmTwo/PrmThree

    I can get my app to work by doing


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.