|
Custom Plugins
|
Top Previous Next |
| <?php
|
|
|
| ### Plugin: factoids
|
|
|
| ## Note, the subroutine name is also the same
|
| ## name as the plugin module file!
|
|
|
| function factoids {
|
|
|
| /*
|
| Pull in any globally needed variables. Note that
|
| in this plugin, we're not going to use some of them,
|
| but for the sake of the example, this is how you'd do it
|
| */
|
|
|
| global $CGI; // Query String or Post paramaters
|
| global $oSQL // OLAP Database Server Connection for lookups
|
| global $language // Language definitions
|
| global $config // Preferences settigns
|
| global $templates // Internal Templates, all preloaded for you.
|
|
|
|
|
| // First, let's construct an SQL Query to get one random fact.
|
| $SQL = "SELECT * FROM facts LIMIT 1 ORDER BY RAND(NOW()) LIMIT 1;
|
|
|
|
|
| // Now, we have the fact, let's format it.
|
| // For the sake of this example plugin, rather than just regurgitate
|
| // it with some HTML around it, let's use an internal template called
|
| // "factoid" that you would need to create under "Hyperseek" as a "LAYOUT"
|
| // style template.
|
|
|
| // Grab the template from the $templates hash (predefined)
|
| $template_text = $templates['hs_admin']['default']['LAYOUT']['factoid'];
|
|
|
| // Note that the template object expects an associative array for use in
|
| // substituting <<variables>> with their actual value, so let's create one
|
| // right now, with our fact text in it. Assume, that the template has
|
| // <<factoid_text>> somewhere in it.
|
|
|
| $values['factoid_text'] = $factoid;
|
|
|
| // Create a new template object
|
| $template = new SubTemplate( array( "front"=>"<<", "back"=>">>", "template_text"=>$template_text, "values"=>$values ) );
|
|
|
| // Merge the values in the associative array from above into your template:
|
| $output = $template->merge();
|
|
|
| // Whatever we "return" here will be spit out into your template
|
|
|
| return $output;
|
|
|
| }
|
|
|
| ?>
|
| $CGI // Query String or Post parameters
|
|
|
| $oSQL // OLAP Database Server Connection for searches/lookups
|
|
|
| $iSQL // OLTP Database Server Connection for writes/deletes
|
|
|
| $language // Language definitions
|
|
|
| $config // Preferences settings
|
|
|
| $templates // Internal Templates, all preloaded for you.
|
|
|
| $searchengine // Search Engine Object for Hyperseek custom plugins, contains specific settings for Hyperseek. You can do a "print_r($searchengine) somewhere in your plugin to get the rundown of the data it contains.
|