Users can add promotional queries to show a specific result, given a keyword, which is returned in a separate branch of the XML (SL_RESULTS). It'd be cool if this module supported that, especially with a theme call such that we could style those results separately.

I'm attaching an example of an XML resultset with a promotional match.

Comments

jweowu’s picture

StatusFileSize
new6.97 KB
jweowu’s picture

Status: Active » Needs review
jweowu’s picture

purdy_nc: Your XML example has an unexpected (to me) set of IMAGE elements in SL_MAIN which are not allowed for by the documentation, which is why I haven't implemented any support for that.

jweowu’s picture

While I'm here, I noticed a few formatting glitches in the code -- a handful of tabs crept into the indentation, a "foreach(" with no intervening space, etc...

You might want to run it through the coder module.

jweowu’s picture

StatusFileSize
new6.85 KB

I had unnecessarily included a couple of lines from google_cse_adv_block_suggestion() in my google_cse_adv_block_subscribed_links()

    $page = isset($_GET['page']) ? $_GET['page'] : 0;
    $response = google_cse_adv_execute(search_get_keys(), $page);

This is the same patch, with those lines removed (and the data variable name changed to $links).

jweowu’s picture

On the topic of unexpected components in the XML, notice that I've provided the original XML in the data passed to the theme function, so themers can still process any XML components which the module did not expect to see.

I haven't made any similar changes to other parts of the module in this patch, but I would suggest this as a useful thing to do in general.

jason_purdy’s picture

Wow, that was fast, jweowu!

The image might be a new feature? Here's their documentation on the front-end of that:

http://code.google.com/intl/en/apis/customsearch/docs/special_results.ht...

jweowu’s picture

StatusFileSize
new7.44 KB

> Wow, that was fast, jweowu!

Pure coincidence, in fact :) I was just about to create the issue in order to attach my patch, and I found that you'd asked for the exact same thing since I'd last checked the queue. For a moment I thought your XML attachment was a patch, and we'd both just implemented the same thing.

So... that image stuff looks fairly official, doesn't it? I guess we just add support for the current XML, and hope it doesn't change.

jason_purdy’s picture

So... that image stuff looks fairly official, doesn't it?

Looks that way... I plan on using it on our site to create custom keywords that we use in our print magazine and highlight the online content associated w/ the keyword. It'll be cool to also have the images in there, too.

I hope this can get folded into the module base soon. :)

jweowu’s picture

FYI, if you've tested the patch and it all looks good to you, please say so. If you've reviewed the code as well, you might set the status to RTBC.

jason_purdy’s picture

I patched the module, but I'm not understanding how the blocks work. I see a new "Google CSE Advanced subscribed links / promotions" block and I added it to my content top region. But I don't see it showing up whenever I use a promotional query. I'm not sure I understand how the module's blocks work.

Thanks!

jweowu’s picture

Hmm.. it's working fine for me with the exact same configuration. Can you verify that:

1) The promotion works correctly when searching via the google interface? (or check the XML being returned, as before).
2) The content top region is being rendered by your page template?

jason_purdy’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new49.06 KB

It works now! I think I wasn't letting enough time lapse between setting it up and it taking effect or something like that. Even the little icon thumbnail is showing up! :)

Now I just need to figure out how to get it to work inside of the results instead of in the content top.

Thanks, jweowu!

jweowu’s picture

Now I just need to figure out how to get it to work inside of the results instead of in the content top.

sites/all/themes/(theme-name)/template.php:

/**
 * Pre-process variables for search-results.tpl.php
 */
function (theme-name)_preprocess_search_results(&$variables) {
  $promotions = google_cse_adv_block_subscribed_links();
  $variables['promotions'] = $promotions['content'];
}

sites/all/themes/(theme-name)/search-results.tpl.php:

print $promotions;
jason_purdy’s picture

Wow ... thanks, jweowu! I'm a Drupal n00b and that helped tremendously!

jweowu’s picture

Perhaps this module should provide its block contents in this fashion by default, with a google_cse_adv_preprocess_search_results(), as a convenient alternative for themers?

meba’s picture

Status: Reviewed & tested by the community » Needs work

Yes, I think that's a good idea. Perhaps a setting to turn on/off this feature and then both block is exposed together with a variable in preprocess? If you do that, I will be happy to commit the patch.