Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Help with basic table - managed via modelAdmin - with display limit & multiple page results

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2 3 4 5
Go to End
Author Topic: 2222 Views
  • UncleCheese
    Avatar
    4085 Posts

    Re: Help with basic table - managed via modelAdmin - with display limit & multiple page results Link to this post

    Make sure you've turned PHP error reporting on, so you can get an error and not just a blank screen.

  • CHD
    Avatar
    Community Member
    217 Posts
  • UncleCheese
    Avatar
    4085 Posts

    Re: Help with basic table - managed via modelAdmin - with display limit & multiple page results Link to this post

    You can usually do it in .htaccess..

    php_value display_errors On

  • CHD
    Avatar
    Community Member
    217 Posts

    Re: Help with basic table - managed via modelAdmin - with display limit & multiple page results Link to this post

    you're fast becoming my hero!

    so, i did that, and it threw out this error:
    Parse error: syntax error, unexpected ';', expecting ')' in /home/vhosts/worldaircraftsolutions.com.sg/httpdocs/mysite/code/Catalogue.php on line 23

    so on closer inspection, looks like there was an non-required ; at the end of line 23. i took that out and the site loaded up fine.
    new part of that code is:
    return array (
    'ProductList' => $this->ProductList($filter)
    );

    but now...when i try and use the search box, it loads this URL:
    http://www.worldaircraftsolutions.com.sg/catalogue/ProductSearchForm
    which loads "page does not exist"
    do i need to make more templates for this??

    thanks again for all your help!

  • CHD
    Avatar
    Community Member
    217 Posts

    Re: Help with basic table - managed via modelAdmin - with display limit & multiple page results Link to this post

    is there no way i can edit the contents of this file: httpdocs/sapphire/search/SearchForm.php
    in particular, this part:

       /**
        * Classes to search
        */   
       protected $classesToSearch = array(
          "SiteTree", "File"
       );

    to somehow include my product catalogue?
    also... if i can get this all to work, how will the results be displayed? because as the products aren't within a page per say, (they only appear in the table) what will the search results page display?? im a little worried we will get this up and running and the end result will be useless!

    ideally, it should do something helpful to the customer, such as load & highlight the product(s) within the table. (like it does in the modelAdmin backend when you search)

  • UncleCheese
    Avatar
    4085 Posts

    Re: Help with basic table - managed via modelAdmin - with display limit & multiple page results Link to this post

    Absolutely not. You're barking up the wrong tree. The site search form is not going to help you with this.

    I think you're getting a page not found error because you haven't added ProductSearchForm to your $allowed_actions.

    In the controller that contains the ProductSearchForm() function, add:

    static $allowed_actions = array (
    'ProductSearchForm'
    );

  • CHD
    Avatar
    Community Member
    217 Posts

    Re: Help with basic table - managed via modelAdmin - with display limit & multiple page results Link to this post

    OK i dropped it into the Catalogue.php controller section:

    class Catalogue_Controller extends Page_Controller {

    static $allowed_actions = array (
    'ProductSearchForm'
    );

    }

    now when i try and search i get:

    Website Error
    There has been an error

    The website server has not been able to respond to your request.

    here's what my full catalogue.php file now looks like:

    <?php
    class Catalogue extends Page {
    public function ProductList ($filter = null){
    if(!isset($_REQUEST['start'])) $_REQUEST['start'] = 0;
    $limit = $_REQUEST['start'].",25";
    return DataObject::get('Product', $filter, null, null, $limit);
    }

    public function ProductSearchForm() {
    return new Form (
    $this,
    "ProductSearchForm",
    new FieldSet(new TextField('s','')),
    new FieldSet(new FormAction('doProductSearch','Search'))
    );
    }

    public function doProductSearch($data, $form) {
    if(isset($data['s'])) {
    $filter = "SomeField LIKE '%".Convert::raw2sql($data['s'])."%'";
    }
    return array (
    'ProductList' => $this->ProductList($filter)
    );
    }

    }

    class Catalogue_Controller extends Page_Controller {

    static $allowed_actions = array (
    'ProductSearchForm'
    );

    }

    ?>

  • UncleCheese
    Avatar
    4085 Posts

    Re: Help with basic table - managed via modelAdmin - with display limit & multiple page results Link to this post

    You need to put your site into dev mode. You shouldn't be running in live mode until you're in production.

    Director::set_environment_type('dev');

    That will allow you to see descriptive errors.

    And did you notice that the query I gave you was just using placeholders for your fields? e.g. "SomeField".. make sure you go through and customise it as needed. I'm sure that's throwing a database error.

    2222 Views
Page: 1 2 3 4 5
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.