How to build search into your site with JQuery and Yahoo!

Yahoo have a hard time fighting off the image of being bridesmaid to Google’s bride. However, they have a decided knack for turning out really cool developer toys! For example, check out the Yahoo User Interface library, Yahoo Pipes, or their latest baby, Yahoo BOSS.

Short for ‘Build your Own Search Service’, Yahoo have pretty much opened up their entire search service via an API. With an unrestricted number of queries, and complete control over presentation of results, you can really go to town with this one!

Getting started is easy; simply get yourself an API key here. Go on, I’ll wait.

With that done, anyone with basic knowledge of PHP and JQuery can easily build a search application!

Check out my demonstration here.

There are two pages involved in this demonstration. The first page displays the form, and contains the necessary JQuery code to fire off an AJAX request to the second page. The second page takes the posted value, fires off a request to the API, and returns the result.

Without further ado, here’s the JQuery:

    $(document).ready(function(){
      $('#results').hide();

      $('#search').click(function(){
        $('#results').hide();
        searchterm = $('#searchterm').val();
        $.post('getresult.php', {query: searchterm}, function(data){
          $('#results').html(data).show('slow');
        });
      })
    })

Nothing too horrendous here; hide the results division, grab the term to be searched for, fire off an AJAX request, and put the returned data in the results div. Show it slloooooowly. :)

The code in ‘getresult.php’ isn’t much more complex; you can see it here.

That’s all there is to it! (At least for this very basic example.)

Once again, you can see a demonstration here.

I’m sure there must be loads of ideas for mashups out there; let’s hear some of your thoughts!

Posted by admin on July 31st, 2008 3 Comments

New search engine launches, sucks

Today sees the launch of Cuil (pronounced ‘Cool’), a brand new search engine launched by ex-Google employees.

So far, the launch has not gone smoothly. Having tested it quite a bit today I can report the following:

  • It’s really, really slow just now. Probably just teething issues, but not a good sign.
  • “No results because of high load…Due to excessive load, our servers didn’t return results. Please try your search again.”
  • Nasty interface. A three column layout for results by default (ew!) means that I don’t immediately know where there most relevant results are. I’ve been trained to read search results top to bottom since the days of AltaVista - I am supposed to be reading left to right? One column then the other?
  • Related searches at the top, and related categories on the right. Wha? Where? Who?
  • Their about us page returns a 403 forbidden error!
  • Thumbnails for search results that don’t relate to the content (for example, superstring theory - NSFW! Well spotted by digger Crypticlabs)

The performance issue on day one are forgivable; the usability issues less so. With excessive AJAX, and the issues mentioned above, the site is uncomfortable to use, at best.

Having said all that, I hope they do manage to provide an alternative to Google; everyone will benefit from a more competitive search market (rather than Google eating an ever-increasing slice of the pie), and their committment to privacy is laudable.

However, they’ve got a long, long way to go before they can match the power and simplicity of the big G.

Have you tried Cuil yet? What have your experiences been like?

Posted by admin on July 28th, 2008 4 Comments

Modules and Components in Joomla & which banner solution to choose

I’ve received a surprising number of questions and comments from users regarding my Easy Ad Banner component and module for Joomla.

One user asked whether he should be using the module or component to display his banners - good question! For the banner system I’ve developed, the module will display one random banner on each page load. (And will look at the date to pull a current one.) The component will load every valid banner onto the page, in a random order.

A component typically puts content in the main body of the page. You’ll create a link from the menu to the component, and the contents of this component will appear when you click the menu. In our case, the component also creates the admin interface, so you will always need to use the component.

A module, on the other hand, typically sits on every page (although you can choose what pages it will appear on.) While components appear in the main body of the page, modules will typically sit in the sidebar, the header, or the footer of the page. You can’t create a menu link to a module, the way you could with a component.

So you have the following decision to make:

1) “I want the advert(s) to appear in the main body of the page and possibly create a menu link to it.”

You should download only the component. Once it is installed, sign in to the admin area, and go to Components->Advertising. Add new banner(s) as appropriate. Once that’s done, create a menu item in the usual way. The type of link should be ‘advertising->default layout’. Save your menu item, and you should now be able to see the page.

2) “I want the banner to appear on every page, or in an area of the page that is NOT the main content area.”

Follow the steps above, but don’t create a menu item. Install the module. Go to Extensions->module manager, then click on the cross next to ‘random banners’ to enable it. Click on the words ‘Random Banners’ to edit the settings of the module. From here, you can change some of the settings - which pages the module appears in, the module position (left, right, top etc) the CSS class, the title of the module, and more. As long as you’ve activated it, the module should appear in the desired position.

Hopefully this basic information will help some of you out a little bit. You can download the module and component here.

Posted by admin on July 23rd, 2008 1 Comment

Joomla banner module

I’ve written a companion module for my Joomla advertising component.

This module loads a random banner from a user-supplied list, based on dates supplied by the user. It accepts both flash files (.swf) and images.

You’ll also need to download the component to use this module.

Go to the downloads page here!

Posted by admin on July 20th, 2008 2 Comments

New PC - 2/3 purchased!

As I mentioned before, my elderly computer is on the way out.

Although making the switch to Ubuntu certainly extended the lifespan of my home PC (I would probably have chucked it out of the nearest window otherwise), I’ve been gradually picking up components for the last few months now, ready to build myself a new monster to be proud of! Besides, I’d lose my geek card if I told anyone the stats of my current box…

What I’ve picked up already:

  • 500Gb Seagate hard disc
  • 4GB RAM (Geil)
  • Asus P5K Motherboard
  • 1 * cheap DVD writer

Still to get:

  • Intel E8500 (It was going to be the E8400, but the E8500 has come down to E8400 prices recently)
  • Radeon 4850
  • An as-yet-undecided case / power supply
  • Shiny new keyboard and mouse. No point splashing out on all that hardware if your input devices are old, crusty, germ-filled, chocolate covered health-hazards!

I’m still not sold on the advantages of quad-core computing just yet. The main advantage of building my own PC will be ease of upgrading later, so maybe in a year or two, I might be changing my mind!

As for operating system, I’m still undecided. I’ve had a great experience with Ubuntu, but I’m itching to try out other flavours of Linux - with Fedora and OpenSuse being top of the list.

Look out for some unboxing photos soon!

Posted by admin on July 16th, 2008 2 Comments