By webcomm on
anyone know how to theme the search results in D6?
The default search results page is structured like so...
- Title
- Search form
- "Search Results" heading
- Search Results
I just want the "Search Results" heading and the results. I can get rid of the search form with display:none in my CSS, but can't do the same for the page title because it's in h2 tags and I use those throughout the site.
thanks.
Comments
"Documentation" -> "Theme
"Documentation" -> "Theme guide (Drupal 6)" -> "Overriding themable output" -> Working with template suggestions
Copy search-results.tpl.php from modules/search to your theme directory, and theme however you like.
===
"Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime." -- Lao Tzu
"God helps those who help themselves." -- Benjamin Franklin
"Search is your best friend." -- Worldfallz
I copied
I copied search-results.tpl.php to my theme directory, but that template does not contain the page title, which is what I want to edit. Right now I have a double page title on the page, like so...
Search
Search results
How do I eliminate one or the other? It looks like I can get rid of the double title by editing modules/search/search.pages.inc, but I would rather do it in my theme if possible.
If I add this code to my template.php, my whole site goes blank as soon as I delete my template cache...
phptemplate!
you need to call the function phptemplate_preprocess_search_results otherwise it won't work, because you are redeclaring a function that already exists in modules/search/search.pages.inc
My bad I missed that you
My bad I missed that you just wanted to remove the title-- that is not part of the content of the search results but rather part of the page.tpl.php file.
Depending on your theme, you might be able to do it with css by using a search body class as a predecessor to the title (zen provides such a body class). Other than that you may have to put some logic in the page.tpl.php or template.php to indicate when you're on a search page with an additional class or variable. I would check out how the zen theme does it for a possible solution.
===
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz
Come across the same issue
Come across the same issue with title and if you digged into the codes and you'll see the title is themed by box.
So you need to copy the box.tpl.php from system folder to your own theme folder and style it accordingly.
And here's what I did.
You could also try the string
You could also try the string overrides module for changing the title.
Hydrant Ltd
www.hydrant.co.uk
I want to add some div's to
I want to add some div's to create theming for the search box on the result page. Does anyone know how to alter the search form in the page mentioned by webcomm?
hook_form_alter
Hi,
To alter the search forms, you'll have to write a custom module with a hook_form_alter function defined (http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hoo...). You can play with this by doing a print_r on the $form variable from within the function. You'll be looking for the search_form id. Modification of the $form array will update your form. Just make sure to name your module something that starts with a letter after s in the alphabet. (So that hook_form_alter will have access to the entire, assembled form when the hook is called.)
For information on how to theme the search_block_form (the form enabled as a block for, say, your header) see: http://drupal.org/node/154137.
you can try
you can try http://drupal.org/project/ds (and contribution http://drupal.org/project/nd_contrib)
you can make easily what you want for search results
Node Displays
Thanks for the tip on this module. I hadn't come across to it to date and I must say it really speeds up development in terms of layout, etc.
Theming the Title in the search results page for Drupal 6.x
Hi,
I came across this thread while trying to do the same. As it turns out, the Core Search module uses the box template (box.tpl.php in your theme's directory - http://api.drupal.org/api/drupal/modules--system--box.tpl.php/6 ) to theme the results. You can see the calls to the theme function in the search.pages.inc file at http://api.drupal.org/api/drupal/modules--search--search.pages.inc/funct... (it's in the search_view function).
The box theme is only used in two places - comments and search results. It is used so infrequently, in fact, it was deprecated for Drupal 7. So, note well that this technique is not valid for Drupal 7.
Since template files are just php files at their heart, you can replace the default box.tpl.php in your theme's directory with something like:
The "my_search_results_class" of course, would be defined in the style.css file for your theme. And of course, it need not be a class if that doesn't meet your needs.
Obviously, there is more than one way to handle this in the box.tpl.php file but I figure this is a start for those who want to experiment. I googled for some time and then finally broke down and looked at the search module's source. Alternately, you might handle this with a preprocess function in your template.php file. But it helps to know the hook you'll be looking for is "box."
Other implications, including what you can do with access to the $content variable, I leave as an exercise for the reader to explore.
In the interests of the community, I hope this helps someone.
Changing the Search Results Title
I had the same issue. I solved it by adding the following to my page.tpl.php page
/sites/all/themes/mytheme/page.tpl.php
[code]
if ($title=="Search")$title="Search Results";[/code]
Thanks for this, great help.
Thanks for this, great help. I always forget about the Box template!