Welcome to Geeklog, Anonymous Friday, April 12 2024 @ 10:23 am EDT

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
Text Formatted Code
    function Search()
    {
        global $_CONF;

        // Set search criteria
        if (isset ($_REQUEST['query'])) {
            $this->_query = strip_tags (COM_stripslashes ($_REQUEST['query']));
        }
        // ,,,,
 
to
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.
 Quote

All times are EDT. The time is now 10:23 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