Posted by zbricoleur on January 16, 2008 at 8:02pm
I think this will turn out to be something stupidly simple, but I've been trying to figure it out for an hour or more and I'm stumped.
I have a custom theme for which $search_box is not being set. The search box shows up fine in Garland, so I know that I have search enabled. I have it set so that the user has no choice about seeing it. And yet...
<?php if ($search_box): ?><div class="block block-theme"><?php print $search_box ?></div><?php endif; ?> in Garland shows the search box, but the same code in the custom theme produces nothing.
Any help appreciated.
~Matt
Comments
On page
On page admin/build/themes/settings/theme-name, is the box "Search box" checked?
gpk
----
www.alexoria.co.uk
gpk
----
www.alexoria.co.uk
Yeah, I'm an idiot
That was the problem, all right. I thought I had hunted down every Search related setting in the admin interface, but there was one I had overlooked. Thanks, gpk, good call.
:-)
That one has probably caught us all out at some stage. Which is why we now remember :-)
gpk
----
www.alexoria.co.uk
gpk
----
www.alexoria.co.uk
Search box not showing
I too have a custom theme where the search box is not showing, but I can see the search in my admin site, which is using chameleon. I verified the "Search box" is checked under administer/site building/themes/settings/theme-name.
In page.tpl.php, when I check the following, $search_box is empty:
<?phpif ($search_box):
?>
<?phpprint $search_box
?>
<?phpendif;
?>
What else can I check to see why my search box doesn't display?
Thanks,
Paul
What is your custom theme
What is your custom theme based on? Is it a pure PHP theme or a PHPTemplate theme?
Chameleon does not have a theme-provided search box. Maybe what you can see is the search block?
gpk
----
www.alexoria.co.uk
gpk
----
www.alexoria.co.uk
My custom theme
is based on Garland. I just copied all those files and modified to my own needs. I know I must have done something to cause the search block to not appear, but I can't find anything.
Do the relevant roles have
Do the relevant roles have search permission on admin/user/access page?
gpk
----
www.alexoria.co.uk
gpk
----
www.alexoria.co.uk
That's it!!!
Thanks gpk. I spent many hours researching only to have the solution be something so simple. Forgot about permissions.
;-) I've lost count of how
;-)
I've lost count of how many times I forgot to set permissions and then couldn't find the feature I was looking for ...
gpk
----
www.alexoria.co.uk
gpk
----
www.alexoria.co.uk
Search Box
Is there a way to override the search_box function.
right now when calling print $search_box; displays a from with text box and submit button, I want to customize this form (eg: I dont want the button, etc etc)
I dont have the permission to edit the core modules, so i cant edit the search.module file. so i need to override this. Is there any way to do this
thanks
Sumesh
It depends on what you want to do
You can do some manipulation by using template.php in your theme to override the search.module functions theme_search_block_form and theme_search_theme_form.
You can do things like hide buttons using CSS.
You can alter the form itself using hook_form_alter in a custom module.
You don't want to edit search.module; that will just cause you problems down the road.
I've got the same
I've got the same problem.
Search box is enabled in theme settings, users have access enabled but I cannot display a search_box.
So I've tried printing the form with the search_box as form_id.
<?phpprint drupal_get_form('search_box');
?>
The form of course displays properly but when I submit the form/do a search (for example I'm searching for 'keyword') it redirects me to /search/node instead of /search/node/keyword.
Any idea what could go wrong?
I am too having exact same
I am too having exact same problem. Are u able to solve it ?
Some pointers ...
hook_forms() is used to "alias" the form_ids "search_theme_form" and "search_block_form" to the form builder function search_box(), in http://api.drupal.org/api/function/search_forms/5.
The forms are then "called" in http://api.drupal.org/api/function/search_block/5 and http://api.drupal.org/api/function/phptemplate_page/5. The latter populates page.tpl.php variable $search_box iff theme_get_setting('toggle_search') returns something that evaluates to TRUE.
Try using "search_theme_form" in place of "search_box" in yr drupal_get_form() call (search_box() expects an argument - the form_id). Actually with this info you should be able to get the proper $search_box working anyway ...
gpk
----
www.alexoria.co.uk
gpk
----
www.alexoria.co.uk
Can you give an example of
Can you give an example of code. I am lost on this one too. Got it on one site that had it already on the theme, on my custom theme I can not get it!
Thanks
MGParisi
Toasty Art, An Online Premium Art Gallery
use drupal_get_form('search_theme_form')
<?php
if (empty($search_box)) { $search_box = drupal_get_form('search_theme_form'); }
echo '<div class="search-box">' . $search_box . '</div>';
?>
I wish i understood why your
I wish i understood why your solution just worked - BUT IT DID! THANKS!!! Everything else I tried failed. I shared the same sentiment as many other prior posters. $search_box continued coming up empty. I was using an Artisteer custom designed template - maybe that had something to do with it??
Now, off to work to try to lose the fancy SEARCH BUTTON Artisteer wants to insert and to insert a simple default, small because i am burying it in my footer block. Any takers on the simplest way to do that?
+1 on the idiot feeling
+1 on the idiot feeling
"I would rule the world - If only I had the source code"
R.A.Smith -- "ƒrÅzRâ§"
http://www.exterbox.com