Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Help with basic table - managed via modelAdmin - with display limit & multiple page results


Reply

36 Posts   2527 Views

Avatar
UncleCheese

27 August 2010 at 6:04am 4085 Posts

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

Avatar
CHD

27 August 2010 at 6:08am Community Member, 218 Posts

How do i do that please? :-)

Avatar
UncleCheese

27 August 2010 at 8:12am 4085 Posts

You can usually do it in .htaccess..

php_value display_errors On

Avatar
CHD

27 August 2010 at 11:11am Community Member, 218 Posts

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!

Avatar
CHD

27 August 2010 at 11:24am Community Member, 218 Posts

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)

Avatar
UncleCheese

27 August 2010 at 11:44am 4085 Posts

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'
);

Avatar
CHD

27 August 2010 at 11:25pm Community Member, 218 Posts

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'
);

}

?>

Avatar
UncleCheese

28 August 2010 at 2:47am 4085 Posts

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.