Hello all,
I thought I'd post this here, as I know from looking that there's a bit of interest in this functionality. Essentially I just took the AKOBook Mambot search function and modified it to search the AKOStaff tables. I can take very little credit for this, as its based on the akobook search mambot by Arthur Konze. However, just so he doesn't get support requests for this, I've added my own information. If I'm in the wrong, could somebody please let me know? I'm a designer, not a lawyer.
This is a very quick and dirty hack, with absolutely no extra logic built in, but I'm new at this so bear with me.
Download the AKOBook component, unzip it and look at the files in there. Essentially I just changed the akobook.searchbot files and renamed them to akostaff.searchbot. The XML file looks something like this:
Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<mosinstall version="4.5.1" type="mambot" group="pat">
<name>AkoStaff Searchbot</name>
<documentElement>akostaff.searchbot</documentElement>
<creationDate>03.12.2004</creationDate>
<copyright>AKOStaff search hack by Andrew Hankinson</copyright>
<author>Andrew Hankinson</author>
<authorEmail>N/A</authorEmail>
<authorUrl>adc.acadiau.ca</authorUrl>
<version>1.0</version>
<description>AkoStaff Searchbot lets you search through your AkoStaff items</description>
<files>
<filename mambot="akostaff.searchbot">akostaff.searchbot.php</filename>
</files>
<params />
</mosinstall> Then, the akostaff.searchbot.php looks like this: (only relevant portions have been left in.)
PHP Code:
<?php
/** Register search function inside Mambo's API */
$_MAMBOTS->registerFunction( 'onSearch', 'botSearchAkoStaff' );
/**
* AkoStaff Search Engine
* @param array Named 'text' element is the search term
*/
function botSearchAkoStaff( $text ) {
global $database;
$text = trim( $text );
if ($text == '') {
return array();
}
$database->setQuery( "SELECT name AS title,"
. "\n biography AS text,"
. "\n staff_in AS created,"
. "\n 'Staff' AS section,"
. "\n CONCAT('index.php?option=com_akostaff&Itemid=100&func=fullview&staffid=',id) AS href,"
. "\n '2' AS browsernav"
. "\n FROM #__akostaff"
. "\n WHERE biography LIKE '%$text%' OR name like '%$text%' or position LIKE '%$text%'"
. "\n AND published='1'"
. "\n ORDER BY id"
);
return $database->loadObjectList();
}
?>
As you can see, I've made some concessions - it's using the "staff_in" as the published date, which is probably bad, and uses a hard-coded "Staff" for the section.
After that, simply zip those two files up, install it on your site, publish the bot, and voila!