Jump to:

3430 Posts in 1057 Topics by 734 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: 890 Views
  • merrick_sd
    Avatar
    Community Member
    94 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

    http://dev.mydomain.co.uk/property
    if i go directly to the page i do not get an error.

    class EstateCategoryPage_Controller extends Page_Controller {
    static $allowed_actions = array(
          'show','EstateItemList'
       );

    //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);
        $PaginatedList->setPageLength(2);
        $PaginatedList->setLimitItems(1);
        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
    http://dev.mydomain.co.uk/property//action/params/params/

    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
    http://www.silverstripe.org/data-model-questions/show/11817

    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.
    660          
    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
    Avatar
    Forum Moderator
    5489 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(
    'show','list'
    );

    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
    Avatar
    Community Member
    94 Posts

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

    many thanks that worked.

    http://mydomain.com/property//list/29/Swansea/tolet

    eg:
    http://mydomain.com/property//$Action/$EstateCategoryPageID/$Area/$OfferStatus

    http://doc.silverstripe.org/framework/en/topics/controller

    I have
    mysite > routes.yml
    ---
    Name: myroutes
    After: framework/routes#coreroutes
    ---
    Director:
    rules:
    '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

    mydomain.com/mypage/myaction?ECPID=whatevervalue&Area=whatevervalue&OfferStatus=whatevervalue

    890 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.