Customizing Search Scenario


Which is the best practice for diferent search (on seach scenario) results ?

For example

I want the result on search in CGridview be diferent according to language or user permissions and so on

I thought to pass a parameter in search Model method (public function search($extra=null)) to achieve that

but I don’t know if there is a better way.

Has anyone better aproach for that?


Anyone please ?

I doubt that there’s a standard way to do this. If you don’t need to handle too many different search scenarios, you could write separate search methods for each situation. That would mainly be useful if you were doing searches in different parts of an application.

For instance, you might have search methods called searchAdmin() and search() which are used in an admin grid view and the regular site search respectively. The second could be much more restrictive than the first, to prevent users from constructing searches that include fields that they shouldn’t control.

If you need it to be more flexible than this - which seems to be the case - then I don’t think there’s a recommended way to do it. Your approach of passing additional data into the search method seems as good as any.

Thanks Keith,

I think the combination of two or more variety search methods (as you said) and one more with parameters, covers all cases