Welcome to Geeklog, Anonymous Thursday, November 28 2024 @ 08:25 am EST
Geeklog Forums
Search class hack:
Status: offline
jmucchiello
Forum User
Full Member
Registered: 08/29/05
Posts: 985
In this thread my answer to the question involves the search page. But I feel it's an incomplete answer since the page is listed as "Search Results" and has other "search" related text on it. It would be nice if the Search class could be called independently of the URL passed in. So here's the hack. Change the constructor for Search from
{
global $_CONF;
// Set search criteria
if (isset ($_REQUEST['query'])) {
$this->_query = strip_tags (COM_stripslashes ($_REQUEST['query']));
}
// ,,,,
to
{
global $_CONF;
if (empty($A)) $A = $_REQUEST;
// Set search criteria
if (isset ($A['query'])) {
$this->_query = strip_tags (COM_stripslashes ($A['query']));
}
// ,,,,
Now you can call the search function from code with your own criteria.
'type' => 'stories',
'topic' => 'plugins',
'results' => 20,
'page' => 1
);
$search = new Search($args);
$retval = $seach->doSearch();
Of course a better interface to $this->story_results would also help but that's beyond the scope of a hack. Something that broke up the _formatResults function into its components so the caller could create the table outside of the "search took 1.03 secs" stuff.
Text Formatted Code
function Search(){
global $_CONF;
// Set search criteria
if (isset ($_REQUEST['query'])) {
$this->_query = strip_tags (COM_stripslashes ($_REQUEST['query']));
}
// ,,,,
Text Formatted Code
function Search($A = null){
global $_CONF;
if (empty($A)) $A = $_REQUEST;
// Set search criteria
if (isset ($A['query'])) {
$this->_query = strip_tags (COM_stripslashes ($A['query']));
}
// ,,,,
Now you can call the search function from code with your own criteria.
Text Formatted Code
$args = Array('type' => 'stories',
'topic' => 'plugins',
'results' => 20,
'page' => 1
);
$search = new Search($args);
$retval = $seach->doSearch();
Of course a better interface to $this->story_results would also help but that's beyond the scope of a hack. Something that broke up the _formatResults function into its components so the caller could create the table outside of the "search took 1.03 secs" stuff.
10
11
Quote
All times are EST. The time is now 08:25 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content