By morrowc on
I can use search-result.tpl, search-results.tpl, search-results-node.tpl etc to theme parts of the Search Results page. However, these only allow me to theme the pager and results list. Can anyone point me to the file(s) I need to modify the ENTIRE search results page, including the search form, the H2 header, and so on?
Specifically, I'm looking to modify the H2 content, swap it and the form so that the header comes first, and insert some custom wrapping HTML/PHP at the top and bottom of the results page.
Comments
...
page.tpl.php template suggestions use Drupals internal path - therefore its page-search.tpl.php
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
Thanks for your reply. Hmm...
Thanks for your reply. Hmm... so my only option is to recreate the entire page.tpl.php HTML from top to bottom? That wouldn't be ideal, but I suppose it could be done.
I guess what I'm looking for is the file that sits between search-results.tpl.php and page.tpl.php - a file which generates the string that eventually gets put into the $content that is available on the page.tpl.php file. Does such a thing exist?
not in $content (I think)
Hi morrowc,
I'm looking for exactly the same thing. Search is definitely pulling from box.tpl.php in order to render its title <h> element and its $content variable. You can check that by looking at your source - you'll probably see <div class="box"> the header, and the search results (but not the form). But that means that the form is not in $content because it's occuring above the header element.
I think search is writing the form separately (not bundling it into $content). I want to dot the same kind of thing - put the "Search Results" header above the form and the search results.
Anyone?
...
Use if arg(0) == 'search' to conditionally hide the box title and the same condition to do a drupal_set_title to change the h1 title of the search page.
http://api.drupal.org/api/function/arg
http://api.drupal.org/api/function/drupal_set_title/6
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
Nice! Thanks jmburnz!
Nice!
Thanks jmburnz!
Edit: thought I'd include exactly what I did...
1. Copy box.tpl.php to your theme folder.
2. Inside, conditionally set the title to appear (with markup) or not.
3. I enabled a page-search.tpl.php (you can't just do this - you need to add some code in template.php so that your theme recognizes things like: page-.tpl.php
4. In page-search.tpl.php, I inserted the H1 where it normally appears on node-pages (this is specific to my setup)
*admittedly, having to create a whole page template just to put a header in there is probably a bit of overkill. But it does open up the possibility of completely altering the look of the search page. The search form will still appear above search results, but at least we can get rid of that h3 in the middle now...
...
For changing the page title you can do this in themename_preprocess_page, so you dont need that extra template :)
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
Nice - I like that solution
Nice - I like that solution better. My issue is that my regular page.tpl.php file does not display the title - I rely on the node templates to do that. So on pages with no node display, I get no title displayed....
Hmm... you know, I can't believe I never thought about this, but just turning *off the node titles in node.tpl.php for (single node displays) might be a much more efficient way to do things, allowing page.tpl.php to display them instead (because then I can use View overrides to title appear in the same place, and get the h1 tags out of the view headers)...
Spring cleaning (sigh)... ;)
Thanks again, jmburnz!
Me too! Subscribing
Me too! Subscribing(see above reply) ;)