Search

A new Extension, “Data Source: Google Custom Search Engine” is now available for download. Comments and feedback can be left here but if you discover any issues, please post it on the issue tracker.

Add Google Custom Search to Symphony 2!

This extension uses Google AJAX API for non-javascript environments to get search results and add them to XML.

You can also setup Custom Search Engine to restrict search to one site, or only those sites You prefer.

Download

Neato!

Sweet.

Nice work, ahwayakchih. Just playing around with it now; my only suggestion thus far is that it'd be nice to be able to change the URL parameter from the preferences page.

Also — not your fault obviously — but it's sucks that the AJAX API is limited to a maximum of 8 results. Makes this extension far less useful than it could be.

but it's sucks that the AJAX API is limited to a maximum of 8 results. Makes this extension far less useful than it could be.

This is a limitation of Google's API?

Unless I'm missing something, that seems to be the case.

Thanks everyone for kind words :).

my only suggestion thus far is that it'd be nice to be able to change the URL parameter from the preferences page

You're right. I wanted to implement that and make data-source configurable just like built-in data sources (so one could create more than one Google search data sources, e.g. one for "news" section and another for "products" section), but i think it's not possible (at least not through built-in data source wizard).

So for now i just implemented settings for parameter names :).

AJAX API is limited to a maximum of 8 results

This is a limitation of Google's API?

Yes.

It is possible to workaround 8 results limit by doing repeated calls. I did something like that for Drupal based site, but it was used for internal data. I'm not sure if i should implement it here - i don't want to make Google angry. I mean, they already give us search functionality for free (and without adds so far), so trying tricks to workaround their wishes is not cool :).

Makes this extension far less useful than it could be.

I think it's very useful anyway. 8 results is not that much less than regular 10. I implemented it on Symphony 1.7 based site, with pager ("next" and "previous" page links) and it works pretty well with Google Custom Search Engine configured to use data only from that site - looks and works like it was built-in search function :).

Version 2.1 is ready on github.

I didn't mean to sound like I was dissing your work — it's a great extension and something that I'd been meaning flesh out into a proper extension myself. I just can't see myself using a search that only returns 8 results. I already hate pagination enough :p

Perhaps it'd be worth doing up a version for Yahoo's BOSS API, I'm pretty sure it doesn't have the same numeric limitations that Google's AJAX API does.

I just can't see myself using a search that only returns 8 results. I already hate pagination enough :p

Heh :).

Maybe i'm just lucky, but whenever i know what i'm looking for (i mean: i know how to ask Google for it), i get best results from first ~5 items. When i'm not sure how to formulate query, then usually it takes ~20 (two Google pages) items to find something. There's very little chance i find anything in items above 30. So (again: usually, because there are extreme/corner cases too), best way for me is to get 1st page of results, find out new key words there, and formulate new query to get better results. That's why i think 8 items is more than enough for most cases anyway.

And that's for searching through whole internet ;).

This extension was made with custom search in mind, where You restrict search to one or just a few sites. That means that there will be much less result items there, and it will be easier to find what You're looking for (if it exists somewhere on those sites of course).

Perhaps it'd be worth doing up a version for Yahoo's BOSS API, I'm pretty sure it doesn't have the same numeric limitations that Google's AJAX API does.

I did check it long time ago and didn't like it for some reason (that's why i went Google way). I just checked docs again, and it's much better than i remembered it ;).

Still, Yahoo also sets limit (tough much higher than Google: 50 vs 8), and they require BOSS App ID (Google makes key optional). Format of search results is a bit different for both, and language parameters are different too, so i guess it would be better to make Yahoo data source as separate extension. Or maybe just separate data source, but they would require separate settings pages.

Makenosound, Yahoo! search made as separate extension.

I also fixed few things in GCSE module, so new download is advised :).

New version ready on github.

Now it supports Symphony parameters, just like "built-in" data sources. So, for example, You can pass CSE ID through parameter, or get it from another data source ($ds-cse_id ?:), to create different search boxes, get different search results, etc...

any plans of making a search that doesn't require indexing? (like for sites requiring a login to see the content)

wtdtan, i didn't try it, but xjosie729 implemented event for "local search". Have You tried it?

i didn't see that thread, ahwayakchih. i'll give it a shot. thanks

I'm having a strange issue with this extension:

Only the first 8 pages of results will output, even though gcse/pagination-info/@total-pages is greater. If $url-p goes above 8, I get 'no data found'. $data->responseStatus is returning 400, which is a syntax error.

ashooner could You post search string You tried?

Great plugin however i have an issue where the pagination information is never accurate. it jumps around. It will say 16 total pages but in reality there are only 8. Sometimes it will only display 4 results with more then 8 results. seems random.

IPOTS, of course there may be a bug somewhere in code, but total pages will never be accurate, because it depends on number of total results reported by Google (it does not download all results and then calculate how many pages there will be), which often changes between pages. The same can be seen on regular Google search page, e.g., there are links for 7 pages, but results end on 4th page.

Other than that it works great! I am happier with this extension then the Yahoo Boss one. You may want to consider wrapping the title and description in a CDATA tag because html entities ended up breaking the XML. I had to add that part in myself.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details