Ajaxified Search Everything

Wordpress never had a search function that’s worth shouting about. The “stock” search simply searches posts, and leaves pages and comments out in the cold. Seaching blogs with hundreds of posts isn’t easy either. If it’s homepage shows only 5 posts, then you’d have to navigate through pages and pages of search result.

Dan Cameron pulled together some hacks and this plugin to create a wonderful plugin that allows searching of pages and comments. But then again, searching thousands of comments take a little more time, and most comments are are bullshit.

So I did some coding and came up what you could call “Ajaxified Search Everything”. Firstly, through the use of Matt Read’s Custom Query String plugin, I’m able to control how many posts should be shown in a search result page. For a tiny blog like mine, you can show all search results, or you could list 25 per page for a large blog. It doesn’t stop there. Since I’m listing the search results, the post titles might not make much sense right? So let’s preview ‘em!

“Ajaxified Search Everything” is not a plugin, it’s a solution. It’s not for the weak-hearted, you should have some basic CSS+HTML knowledge to customize the way it looks, and JavaScript and PHP for even more customization.

Demo

A working demo, is of course available right here in my site! Just try searching for, say “wordpress”.

Download Away…

I’ve zipped a file that contains all source files. These source files include my search.php and searchform.php templates, a slightly modified version of Dan’s search_everything.php plugin, ase.js for the Ajax behaviours, ase.css to style the search result, and also data.php to do the return a snippet of the post.

Installation

To use ASE, first download Matt Read’s Custom Query String plugin and the source files.

1. We’d like the search page to list every search result, so upload and acitivate Matt Read’s Custom Query String plugin. In your admin panel, goto Options -> CQS. Add a new condition under query, select “is_search” for the condition, and enter “-1″ for number of posts to show.

2. Upload and activate the search_everything.php plugin.

3. Edit data.php and insert your MySQL database username, password, and database name (at line 35). Upload data.php to anywhere in your webserver if you want Ajax enabled previewing.

4. In your header file, add something like the following snippet to your header.php so that the JavaScript file will be included. So of course you’ll need to upload the ase.js to your theme’s folder. You should remember the change http://yourDomain.com at line 62.



5. Next, comes the CSS. I’ve inlcuded the CSS I used in the source files, and commented the parts that can be easily customized to match your theme. I’d strongly suggest that you do your customization by trying out the search page, then save the source as a local html file.

Technical Details

It’s really a simple custom search.php page, with a data.php to get the post preview. I’m not good at writting lengthy documentations, so you should jump straight into the codes. They’re short and simple so I think you’ll find the codes fairly easy to understand. Besides, I’ve added plenty of comments in the codes. So, happy customizing!

11 Responses to “Ajaxified Search Everything”

  1. Ajaxified Search Everything at Dan Cameron 2.0 Says:
    March 4th, 2006 at 9:42 am

    [...] Jonathan Ng just created a new plugin that uses a little bit of my plugin to do some wonderful things for searching in wordpress. May be an added feature in my next release. [...]

  2. Dan Says:
    March 4th, 2006 at 9:47 am

    I love your site.

    I sent a trackback about this post because you’re using my plugin for a MUCH better plugin, it’s awesome.

    Anyways, I love some of the stuff you have here especially the tabs for personal and tech. Mind sharing?

  3. Dan Says:
    March 4th, 2006 at 9:53 am

    Oh duh, I see. I thought you were using ajax for no refreashing but you’re just linking.

    I still like it though.

  4. ken Says:
    March 12th, 2006 at 5:07 am

    Got this working. Searchform.php wasn’t in the zip file so i commented that out. For those installing, be sure to add “more” tags to long content for preview to be practical. Very nice work. How does it do with older browsers? I haven’t tested that yet.

  5. Jonathan Ng Says:
    March 12th, 2006 at 3:41 pm

    searchform.php added to the zip file. As for older browsers, you could list the posts as links, then use javascript to parse through them and convert them back to span.

  6. ???????? » ??“????”?? Says:
    March 14th, 2006 at 3:24 am

    [...] ?????????????????????????????? Ajaxified Search Everything ? WordPress ??? [...]

  7. alenn Says:
    March 19th, 2006 at 12:45 am

    awesome dude,
    btw, please check, there’s something you overlook, your “view post” and “show preview” pictures are stored under local host, lol

  8. Jonathan Ng Says:
    March 19th, 2006 at 10:03 am

    lol.. thanks man.. I was testing with localhost still running.. so didn’t realize that..

  9. Cosmic Lifeform Origin » Blog Archive » AJAX Search Everything Says:
    March 22nd, 2006 at 10:17 am

    [...] Then I notice that it’s already been hacked into an AJAX Search Everything by Jonathan Ng. [...]

  10. Alberto Saavedra 2.0 » Making it simple and useful Says:
    April 4th, 2006 at 9:10 am

    [...] Extended Search. To allow search in comments and other pages with an Ajax interface I use the Ajaxified Search Everything plugin. [...]

  11. Alberto Saavedra 2.0 » Simple y útil Says:
    April 4th, 2006 at 9:13 am

    [...] Búsqueda Extendida. Para buscar en los comentarios y otras páginas con una interfaz Ajax utilizo el plugin Ajaxified Search Everything. [...]

Leave a Reply