I have enabled and configured the module. I can search and it displays the results correctly, but if I click a search result it opens within the iframe. How do I get it to open in the regular window? This is not how the drupal6 module handles search results.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | configurable-tags-2012918-7-7.patch | 2.57 KB | afinnarn |
| #4 | google_cse-search_results-target-2012918-4.patch | 3.51 KB | osopolar |
| #3 | clicking_search_results-2012918-3.patch | 3.07 KB | malcomio |
Comments
Comment #1
malcomio commentedNot sure about results opening in an iframe - I haven't observed that. Do you mean that they open in a new window?
If so, we'll need to create an option to set a parameter to pass to Google.
The documentation is at https://productforums.google.com/forum/?hl=en#!category-topic/customsear...
Comment #2
kruser commentedI found a solution to modify the results page tag here - http://webmaster.tamu.edu/2014/05/09/opening-google-custom-search-result...
in google_cse.theme.inc I had to edit the function google_cse_get_cse_tag() - for me it was adding linktarget="_parent" to the search results:
I hate to hack a module like that, but it worked.
Comment #3
malcomio commentedI'm still not entirely sure what the issue is - on my site, which uses the "Results only" layout, the links all open in the same window, with the target attribute set to "_self".
Here's a patch which makes the target configurable.
Comment #4
osopolarPatch in #3 works for me, it just misses the deletion of the variable google_cse_link_target in google_cse_uninstall(), I added that to the patch.
@kruser: There is no need to hack the module, you could replace the cse_tag completely in your custom theme with your own template google_cse_results.tpl.php
There are many more attributes for the cse_tag, see
Custom Search Element API 2.0 documentation. In almost every case where you want to set something else as defined in google_cse_get_cse_tag() the only option is to customize google_cse_results.tpl.php. Maybe we should add the option to enter the cse-tag code directly. In my case for example the complete tag looks like below. As it takes some time till search results are showing up I'd like to inform the users to be patient (and meanwhile they could watch an animated throbber). If such behavior would be desired by the maintainer I may think about providing a patch for that.
<gcse:searchresults-only gname="google_cse" linkTarget="_self"><div class="google-cse-processing"><h2>Your search is performed</h2><p>Please be patient, the search results will be provided shortly by Googe ...</p><div class="spinner-loader">Loading...</div></div></gcse:searchresults-only>Comment #6
afinnarn commentedI'm changing the title to reflect the eventual directions this issue went. I agree with @osopolar and the idea that the attribute part of the search tag should be configurable. To that point, I will expand on the most recent patch to allow the user to add attributes in a string format...simplest way to do it in my opinion and doesn't tie anything to the actual names of the attributes at the time this would be committed.
Comment #7
afinnarn commentedadding patch.
Comment #9
afinnarn commentedThanks, everyone! Committed to dev branch.
Comment #11
afinnarn commented