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.

Comments

malcomio’s picture

Title: Clicking search results open in iframe » Clicking search results open in new window
Version: 7.x-1.x-dev » 7.x-2.x-dev
Category: Bug report » Feature request
Issue summary: View changes

Not 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...

kruser’s picture

I 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:

    case 'results-only':
      return '<gcse:searchresults-only linktarget="_parent" gname="google_cse"></gcse:searchresults-only>';

I hate to hack a module like that, but it worked.

malcomio’s picture

Status: Active » Needs review
StatusFileSize
new3.07 KB

I'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.

osopolar’s picture

Patch 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>

afinnarn’s picture

Title: Clicking search results open in new window » Add Configurable Attributes to CSE Template.

I'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.

afinnarn’s picture

StatusFileSize
new2.57 KB

adding patch.

  • afinnarn committed 4b72ddb on 7.x-2.x
    Issue #2012918 by malcomio, afinnarn, osopolar: Add Configurable...
afinnarn’s picture

Status: Needs review » Fixed

Thanks, everyone! Committed to dev branch.

  • afinnarn committed 4b72ddb on 7.x-3.x
    Issue #2012918 by malcomio, afinnarn, osopolar: Add Configurable...
afinnarn’s picture

Status: Fixed » Closed (fixed)