PDA

View Full Version : How to stop the search bar from choosing the category?


Bluesplayer
19-11-08, 13:52
Hi

The title is a bit confusing on this. What I want to know is how to stop the search bar from showing the category after a product is selected. I am showing random products on the home page of my site and sometimes people are searching without altering the category beforehand. I have put a little message over the search bar but I would like to show only the 'All Categories' option at all times on the front page. I am loading a different search.tpl for this so I can customize it easily.

Regards
Bluesplayer

Andy
19-11-08, 15:47
If Ive read that right............

in:
elements/search_box.php

find:
$oSmarty->assign('sOptionSelected', '4-'.$oShopCore->oCategory->iId);
and escape it:
#$oSmarty->assign('sOptionSelected', '4-'.$oShopCore->oCategory->iId);
That will default every search to "All Categories" until the user changes it. even if they do, the landing page's search form will default back to "All Categories".

If this mod is just for the homepage and you want to keep the functionality for the rest of the site, instead of escaping it do this:

if(!isset($_GET['rb']){

$oSmarty->assign('sOptionSelected', '4-'.$oShopCore->oCategory->iId);
}
I think thats what you're after :D

Bluesplayer
19-11-08, 16:05
Great - well nearly!

I have this line:

$oSmarty->assign('sOptionSelected', $sOptionSelected);

I don't have what you mentioned above in searchbox. Not sure why unless I haven't upgraded? If I use the code you supplied instead of the above:

#$oSmarty->assign('sOptionSelected', '4-'.$oShopCore->oCategory->iId);

it works fine :) . The other code you mentioned that I would like to try doesn't seem to work and my site refuses to load after I have used it. I put it in various places but the same thing happened. Still the above is a big help. Slight alteration in the code needed?

Regards
Bluesplayer

Andy
20-11-08, 13:50
ah, I was talking V2 which is enormously different, but still works in a very similar way