This module works fine, but it has one limitation I can't live with: I can only use it by navigating to http://site.com/search/google

Instead, I want to embed the search in another page so I can put other text around it. I also want to then use the page as my home page. I can get the latter by creating a page and promoting it to the front page.

How would I get the functionality of search/google embedded in another page?

Comments

mfb’s picture

You should be able to place the Google CSE block on any page.
If you're asking about also embedding the results on some other page, that should be doable although would require some form altering.

bdornbush’s picture

Yes, I can place the Google CSE block on a page, including the home page, but it shows as a block and is hard for me to place the text I want around it.

If I understood your second point, I will have to modify the module to alter the form. I don't know of a way to embed a form like search/google on the front page. That is what I am really looking for. Is there a way?

mfb’s picture

You can modify the display of the form thru your theme -- any drupal form can be themed.

You can also alter any form via hook_form_alter() -- no hacking necessary.

mfb’s picture

One thing I'm thinking as far as feature requests is that the Google CSE results page could be rendered as a block. That would allow the results to be placed anywhere. There would also need to be some means to set the form action (telling the form what path to GET).

bdornbush’s picture

StatusFileSize
new2.01 KB

I found that the requirements I had could be met if I used search/google as my front page. Then I needed a way to put some text around the form, and so that I could provide my client with an easy way to manage the text, I added "prefix" and "postfix" fields to the Admin Settings. The fields are null unless something is entered, so there is no change to the original look unless someone enters something in these fields.

I submit my changes as a patch in case you want to include this in the module, or in case someone else wants to take this approach. Since this is the first time I have created a patch, I hope it works OK. I use Windows for my test system, where I did the editing using Eclipse, and then used Cygwin to create and test the patch file.

I also use the block on other pages on the site so that users can access it from wherever they are on the site. The block is not affected by my patch, so I have the original block and an enhanced page.

mfb’s picture

Version: 5.x-1.4 » 5.x-1.5
Component: Documentation » Code
Category: support » feature
Status: Active » Needs work

Thanks for the patch. It is probably helpful for non-developers.

It should be suffix rather than postfix. And you don't want to call t() on a variable; t() should only be for strings in the code. Also btw you never want to call t(NULL), bad things will happen. Rather than t() it should be something like this: filter_xss_admin(variable_get('google_cse_results_prefix', ''));

And, you need to create a CVS diff, not a regular diff, see http://drupal.org/patch

On the command-line this would be cvs diff -up > my.patch although you can also use Eclipse. Make sure you get a fresh CVS checkout so you are patching against the current code.

mfb’s picture

Marked an older issue as a duplicate: http://drupal.org/node/195948 since this issue has a patch.

mfb’s picture

Marked an older issue as a duplicate: http://drupal.org/node/195948 since this issue has a patch.

bdornbush’s picture

StatusFileSize
new2.21 KB

Here is the revised patch against the latest v5 code. I used diff because I haven't yet figured out how to make cvs diff work from my Windows + Eclipse + Cygwin environment, but I hope that the patch will prove useful. I believe it can be applied when created this way, too.

I appreciate your comments on how to improve the code. I am just learning how to be a developer.

bdornbush’s picture

StatusFileSize
new2.23 KB

I found a very helpful web site, moodle.org, that had a section on how to use Eclipse, including how to generate a CVS patch at http://docs.moodle.org/en/Development:Setting_up_Eclipse#Creating_a_patch.

So here is the CVS Patch.

mfb’s picture

Title: How do I embed the search on a page? » Ability to add text around the form on results page
Status: Needs work » Needs review
mfb’s picture

Status: Needs review » Fixed

Committed to 5.x-1.x; refactored and committed to 6.x-1.x.
Thanks bdornbush!

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.