Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
How would I be able to add a result's page URL, file size, "cached" version, etc.
A list of the preprocess variables (i.e. "$range") would be helpful. Also, where do these go? I tried placing a custom "search-result.tpl.php" file in my theme, but it didn't have any effect.
Comments
Comment #1
jweowu CreditAttribution: jweowu commentedDid you clear the theme registry cache after adding the template file?
Comment #2
jweowu CreditAttribution: jweowu commentedLook at
google_appliance_preprocess_search_results()
andgoogle_appliance_preprocess_search_result()
.You can base your own preprocess functions on those, if you want to add additional template variables.
Comment #3
naero CreditAttribution: naero commentedYes, I cleared it. I'm using Theme Developer (http://drupal.org/themedeveloper), and it is showing saying that the Google Search result is being driven by file: modules/search/search-result.tpl.php, and not from the copied file I placed in my theme.
I ran a cron and cleared all of the caches, but still nothing. Any ideas?
Your 2nd response was helpful, I think. I see all of the hidden data by using the Theme Developer.
Comment #4
naero CreditAttribution: naero commentedI figured this out. Turns out that when you do the theme override, you need to rename any customized template files with the suffix -google-appliance.tpl.php.
Thus, my theme folder has these files:
search-result-google-appliance.tpl.php
search-results-google-appliance.tpl.php
search-results.tpl.php
search-result.tpl.php
This information should be clearly stated either within the official documentation, which is currently linking to a dead URL (http://pajamadesign.com/?p=8), or it should reflected on the project home page. How can this be done?
Comment #5
jweowu CreditAttribution: jweowu commentedThe intention was certainly that the -google-appliance templates were optional, rather than a requirement, which is why the project page has the information that it does, but changing the documentation is indeed probably simpler than fixing that behaviour, given that the project is currently looking for a new maintainer.
I'm setting the issue component accordingly. Hopefully the current maintainer will find a little time to change the text. I would suggest simply adding the following note to what is already there:
"IMPORTANT: If adding search-result(s).tpl.php to your theme (and clearing the theme registry cache) does not have the desired effect, you may need to use the '-google-appliance' versions of these templates, as described above."
Comment #7
dnmurray CreditAttribution: dnmurray commentedI'm running into #5 right now and tearing my hair out. I've had it working with both search-result(s).tpl.php (I think) and search-result(s)-google-appliance.tpl.php and then it suddenly stops working. It seems to stop when I Clear All Cache from my Admin menu pulldown. Clearing theme registry doesn't fix it. /admin/build/themes Save config doesn't fix it. It's been very frustrating.
I currently see that this call
0.6521 47544648 -> drupal_discover_template(array (0 => 'modules/search'), array (0 => 'search-results-google-appliance', 1 => 'search-results-google-appliance'), '.tpl.php') /Users/dmurray1/Sites/pvn-git/svn-repos-pvndrupal/httpdocs/includes/theme.inc:729
in the trace. It only appears to be looking in modules/search. I think I recall seeing an earlier version (when I had search-results.tpl.php, but no search-results-google-appliance.tpl.php in place) when that first argument was "themes/mytheme/templates" (where my templates live). When I renamed search-results.tpl.php to search-results-google-appliance.tpl.php it magically started working. I checked everything in with git, cleared cache, and it broke, again.
Just needed to vent. Hopefully I'll come back and update this post with what the real problem is here.
Edit: this is really weird. Cleared cache, verified that theme_registry:mytheme was gone from cache table. Went to homepage. Verified that theme_registry:mytheme row was rebuilt. Re-ran search. Override templates work (all 4 are in my templates directory). Deleted search-results?.tpl.php, cleared cache, not working. Restored search-results?.tpl.php, cleared cache, works (all 4 are there). Is this normal theme override behavior? At least it's working again. Maybe this will benefit someone.
Comment #8
jweowu CreditAttribution: jweowu commentedYes, you do need to over-ride the base templates even if you only wish to use the -google-appliance variants, otherwise Drupal will not be looking in that directory when processing that theme hook.