1778 Posts in 581 Topics by 555 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1666 Views |
-
Understanding the SearchForm Method

18 June 2010 at 12:13pm Last edited: 18 June 2010 12:15pm
Can someone please explain how to extend the SearchForm class.
My aim is to modify the default text and button text initially, but will probably extend to more changes later.
I have located the function in this file " \saphire\search\ContentControllerExtension.php"
The easy thing to do would be to make the changes in this file. But messing with the core files is not ideal of course.
I have tried extending the Searchform.php class as follows:
Create new class "SiteSearch.php" in mycode
class SiteSearch extends SearchForm {
function __construct($controller,$name){
parent::__construct($controller,$name);
}}
Putting $SiteSearch in my template and I get the default form rendering OK. But I get the error below.
Any help would be much appreciated.
[User Error] Uncaught Exception: Object->__call(): the method 'getviewer' does not exist on 'DataObjectSet'
GET /home/SiteSearch?Search=&action_getResults=GoLine 724 in E:\websites\IRIS\v2\sapphire\core\Object.php
Source715
716 default :
717 throw new Exception (
718 "Object->__call(): extra method $method is invalid on $this->class:" . var_export($config, true)
719 );
720 }
721 } else {
722 // Please do not change the exception code number below.
723
724 throw new Exception("Object->__call(): the method '$method' does not exist on '$this->class'", 2175);
725 }
726 }
727
728 // -----------------------------------------------------------------------------------------------------------------
729
730 /**Trace
* Object->__call(getViewer,Array)
* DataObjectSet->getViewer(SiteSearch)
Line 155 of Controller.php
* Controller->handleRequest(SS_HTTPRequest)
Line 199 of ContentController.php
* ContentController->handleRequest(SS_HTTPRequest)
Line 67 of ModelAsController.php
* ModelAsController->handleRequest(SS_HTTPRequest)
Line 283 of Director.php
* Director::handleRequest(SS_HTTPRequest,Session)
Line 127 of Director.php
* Director::direct(home/SiteSearch)
Line 127 of main.php -
Re: Understanding the SearchForm Method

18 June 2010 at 3:47pm
If you want to override the search form (well the button and the text copy the content from the ContentControlellerExtension class to your Page.php then you can customize it as much as you wish.
-
Re: Understanding the SearchForm Method

18 June 2010 at 7:33pm
Thanks Willr. I think the penny has dropped here! I am kicking myself right now!
Much appreciated!
-
Re: Understanding the SearchForm Method

9 July 2010 at 7:36pm
Thank you for posting this! There are a lot of conflicting posts and this one finally answers how to customise the search form and button in 2.4
b
| 1666 Views | ||
|
Page:
1
|
Go to Top |



