Another one of the plugins that i tried to integrated with my redesign was Addicted Live Search. The plugin is a really nice and simple plugin for wordpress. All I wanted to do with this is have the results show results from both forum and my blog. The first step was to integrated both bbpress and WordPress. Second step hack the plugin.
To complete the hack you will also need to have the following things.
- – The web path to the files in the plugin directory and the files in it
- – Basics of XHTML, PHP, JS
You can download the changed files from here. If you need explanation on the changes or customization. Read on.
The live search plugin has three files that are needed to be hacked
search_results.php - integrate bbpress
js\live_search.js - fix a couple of quirks
css\live_search.css - if you want to customize the plugin
Lets start with search_results.php
Hack the Results
Lets open search_results.php. Between lines 13 and 33, bbPress will fetch the titles matching the query, titles with recent posts matching the query and topics of relevant posts with matching content. If you don’t want any of these to show up in the results just comment out the respective query. Meat of the search is in here.
After retrieving the topics, they are displayed by the topics loop between lines 50 and 61. You can also show the results individually for titles, recent posts and relevant posts. For that adjust the queries on lines 13 and 23 and then run a loop for them.
Uncomment the lines between lines 63 and 65 to show a close results link under the results. In some cases, the results fluctuate before disappearing. If you are having that problem, replace
onclick="ls.close(); return false;"
onclick="Field.clear('s'); return false;"
Showing the Results
The plugin by default adds the results under the search box. But sometimes thats not where you would want the results to be. To place it anywhere else comment out the line 10 from js/live_search.js which looks like this
<code>new Insertion.Bottom(ls.search_form, '<div id="addicted_results"></div>');</code>
Now just place the following div tag anywhere you want.
Customizing the Results Display
Edit the css/live_search.css file to customize your display.
Adding links to Blog Search and Forum Search
You can add links to blog search and forum search on the search results. here is the code that you will add to get the link to the blog results.
<a href="<?php bb_option('uri'); ?>search.php?q=<?php echo $_GET['s']; ?>">Â» more results</a>
And here is the code to get the link to the forum results.
<a href="<?php bloginfo('home'); ?>/?s=<?php echo $_GET['s']; ?>">Â» more results</a>