Make sure you've turned PHP error reporting on, so you can get an error and not just a blank screen.
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
DataObjectManager Module /
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba
Help with basic table - managed via modelAdmin - with display limit & multiple page results
- Previous 10 entries
- 1
- Page 22(current)
- 3
- 4
- 5
- Next 10 entries
How do i do that please? :-)
You can usually do it in .htaccess..
php_value display_errors On
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!
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)
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'
);
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'
);
}
?>
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.
- Previous 10 entries
- 1
- Page 22(current)
- 3
- 4
- 5
- Next 10 entries