I’ve been trying to add a global search function to an admin area with
mixed results. Right now it’s on the index page only and works fine.
Log in and view the admin area at http://anoptic.com/MAR/client/.
My thinking was that I could make it global by moving the function
outside of the switch statement in the controller which didn’t work. I
also tried adding PublicSearch to each case (view and edit) but
nothing. Here’s the controller as it is currently (no global search). <http://pastie.org/398696
What I would do is this. If you want to search within a particular model, then simply add a new case to your switch statement for ‘search_results’ or something like that. Make sure that your search engine points at that. If you want to be able to search across more than one model, then you need to have an application_controller.php (this is useful for other things, too – it’s a helpful place to stash a home page, about this site, contact us, whatever). In that controller, you can do something similar to this:
Pay attention to the $places array. This sets up which models to search, and then provides a column name for each model (unless you have given all of your models a column in common, you’re going to have a hard time linking to the results). This array is set up as ('model_name' => 'column_to_link_by') format.
I only need to search one model (‘mar’). The intent was to replicate
the search feature on the admin index page in the ‘view’ and ‘edit’
pages as well. The current ‘index’ case with search, <http://pastie.org/399889
at the bottom of the switch statement which I thought would allow
me to search from any of the 3 cases (index, view, edit) but it’s not
quite there.
Todd
On Feb 25, 2009, at 7:54 AM, waltd wrote:
If you want to search within a particular model, then simply add a
new case to your switch statement for ‘search_results’ or something
like that. Make sure that your search engine points at that.
This will work, as long as your search field (probably either hard-
coded in /views/index.php or set as a global variable in
config.inc.php) is pointed to http://yourhost.com/mar/search_results .
If it isn’t, then depending on how it was created in the first place,
you can make the change so that it does point there. After that, this
should work fine.
If there is a variable called $search then try defining it again
inside the view and edit cases (overloading the variable) so that it
points where you want it to.
Walter
On Feb 25, 2009, at 12:54 PM, Todd wrote:
I only need to search one model (‘mar’). The intent was to replicate
the search feature on the admin index page in the ‘view’ and ‘edit’
pages as well. The current ‘index’ case with search, <http://pastie.org/399889
at the bottom of the switch statement which I thought would allow
me to search from any of the 3 cases (index, view, edit) but it’s
not quite there.
Todd
On Feb 25, 2009, at 7:54 AM, waltd wrote:
If you want to search within a particular model, then simply add a
new case to your switch statement for ‘search_results’ or something
like that. Make sure that your search engine points at that.
On Feb 25, 2009, at 1:11 PM, Walter Lee Davis wrote:
This will work, as long as your search field (probably either hard-coded in /views/index.php or set as a global variable in config.inc.php) is pointed to http://yourhost.com/mar/search_results . If it isn’t, then depending on how it was created in the first place, you can make the change so that it does point there. After that, this should work fine.
On Feb 25, 2009, at 1:11 PM, Walter Lee Davis wrote:
This will work, as long as your search field (probably either hard-
coded in /views/index.php or set as a global variable in
config.inc.php) is pointed to http://yourhost.com/mar/
search_results . If it isn’t, then depending on how it was created
in the first place, you can make the change so that it does point
there. After that, this should work fine.
I looked, and I’m not sure what you’re up to there. I’ll take another look at the larger picture in a couple hours. It looks like you’re doing a couple of different things at the same time to try to fix it, and missing as a result.
To be more specific, the changes I made in the repo (/trunk/admin/) only involve the config, controller and index template files and should reflect what’s shown at the pastie link below. I’ve been using the Big Book™ and been slowly chipping away at it. I’ve found some of my errors but I’m still not there yet.
T.
On Feb 25, 2009, at 1:34 PM, Walter Lee Davis wrote:
I’ll take another look at the larger picture in a couple hours. It looks like you’re doing a couple of different things at the same time to try to fix it, and missing as a result.
and you have routed your requests for yourdomain.com/mar/
search_results to the mar_controller (which is the default for that
URL, unless you have something else going on in your routing.php that
is “hijacking” search requests deliberately), then you should see
results in your page.
Walter
On Feb 27, 2009, at 4:33 PM, Todd wrote:
To be more specific, the changes I made in the repo (/trunk/admin/)
only involve the config, controller and index template files and
should reflect what’s shown at the pastie link below. I’ve been
using the Big Book™ and been slowly chipping away at it. I’ve found
some of my errors but I’m still not there yet.
T.
On Feb 25, 2009, at 1:34 PM, Walter Lee Davis wrote:
I’ll take another look at the larger picture in a couple hours. It
looks like you’re doing a couple of different things at the same
time to try to fix it, and missing as a result.
and you have routed your requests for yourdomain.com/mar/
search_results to the mar_controller (which is the default for that
URL, unless you have something else going on in your routing.php
that is “hijacking” search requests deliberately), then you should
see results in your page.