jDownloadsownloads.com



Author Topic: Jdownloads_search code  (Read 12760 times)

0 Members and 1 Guest are viewing this topic.

Offline domimal

  • Newbie
  • *
  • Posts: 9
Jdownloads_search code
« on: 27.01.2014 12:09:38 »
Hi Arno,

Jdownloads is really working for me, many thanks for your work, much appreciated!

If possible, I would like to tune the code to my requirements please:

     (1) I would like to alter the Jdownloads_search plugin so that it searches in all fields and not just in 'title' and 'description'.

     (2) Also, I would like to organise the search results (by date, number, etc)

Could you please tell me in which files I can find (1) and (2), so I can go in and change the code?

I hope you can help :)

Kind regards,
Domi

Offline Arno

  • Administrator
  • ***
  • Posts: 12.234
    • jDownloads.com
Re: Jdownloads_search code
« Reply #1 on: 29.01.2014 22:08:11 »
Hi Domi,
you must change it in the jD search plugin php file.
Best Regards / Gruß
Arno
Please make a Donation for jDownloads and/or write a review on the Joomla! Extensions directory!

Offline domimal

  • Newbie
  • *
  • Posts: 9
Re: Jdownloads_search code
« Reply #2 on: 25.02.2014 13:06:35 »
Thanks Arno: This is what I've modified in the jdownloads.php file (in plugins/search/jdownloads) so that the results are always listed in alphabetical order:

  switch ( $ordering ){
        case 'oldest':
            //$order = 'a.date_added ASC';
            $order = 'a.file_title ASC';
            break;

        case 'popular':
            //$order = 'a.downloads DESC';
            $order = 'a.file_title ASC';
            break;

        case 'alpha':
            $order = 'a.file_title ASC';
            break;

        case 'category':
            //$order = 'b.cat_title ASC, a.file_title ASC';
            $order = 'a.file_title ASC';
            break;

        case 'newest':
                    $order = 'a.file_title ASC';
            break;
        default:
            //order = 'a.date_added DESC';
            $order = 'a.file_title ASC';


However, after re-installing the search plugin, I get no changes in the my search results... Is there something I do wrong can you tell?

I hope you can help :p

Offline domimal

  • Newbie
  • *
  • Posts: 9
Re: Jdownloads_search code
« Reply #3 on: 26.02.2014 11:15:39 »
oops... forgot to mention, it's in this function:

  function onContentSearch($text, $phrase='', $ordering='', $areas=null) { 

  $config = JFactory::getConfig();
  $sef = $config->getValue('sef');   
  $user = &JFactory::getUser();
  $user_access = checkAccess();
  $users_access =  (int)substr($user_access, 0, 1);

  $database = &JFactory::getDBO();
  $plugin =& JPluginHelper::getPlugin('search', 'jdownloads');
 
  $plugin = JPluginHelper::getPlugin('user', 'userdirect');
  $params = new JRegistry();
  $params->loadJSON($plugin->params);
  $limit  = $params->get( 'search_limit', 25 );
     
  if (is_array( $areas )) {
         if (!array_intersect( $areas, array_keys($this->onContentSearchAreas() ) )) {
              return array();
         }
  }
 
  if ($text == '') {
    return array();
  }
  $text = trim( $text );
  $text = $database->Quote( '%'.$database->getEscaped( $text, true ).'%', false );

Offline chantas

  • Newbie
  • *
  • Posts: 1
Re: Jdownloads_search code
« Reply #4 on: 26.02.2014 19:30:38 »
Hi Arno,

I work with Domi. We finally figured out what was our problem: We got confused between the Search function that appears with binoculars in the top navi and the jdownloads_search which is a plugin of the Joomla search and which appear in the right navi.

Finally we choose the binoculars one as we wanted to specially edit the layout for the search in our downloads.

Regards,
Astrid

----------------
For those interested:

In the functions showSearchForm and showSearchResult of com_jdownloads/site/jdownloads.html.php,
* I increased the value of the variables jdsearchnumber and searchnumber to 1000 instead of 30 to have 1000 results from the search.

Then in showSearchResult of com_jdownloads/site/jdownloads.html.php,
* I replaced all ORDER BY date_added in the query by ORDER by file_title because I wanted to have my files alphabetically ordered.
* I commented out the usort($files2, '_ctrSort'); because it creates a fucking mess! I do not get this function, it looks it randomizes the results whatever you choose your files to be ordered by. I highly recomment to comment it out.
* Finally in if ($output), I edited the variable $html_form to have my results displayed nicely

Code: [Select]
$html_form .= '<tr width="100%"><td class="jd_search_results"><b>'.$titel_link_text.'<br />'
.'<font color="#006666">'.$out->release.'</font></b><br />'
.$out->author.'<br />'
.$out->description.'<br />'
//.substr($out->description, 0, 400).'...<br />'
.$detail_link_text.'<br /><br />'
.'</td></tr>';

I also replaced the content of COM_JDOWNLOADS_FRONTEND_SEARCH_DESCRIPTION in com_jdownloads/site/language/en-GB/en-GB.com_jdownloads.ini to a more suitable text.

We also used a trick: We concatenated all our information into the long description, so that we have no problem of having all our fields searched or not. As long as description_long is searched, all info are searched:
Code: [Select]
    // new - description_long -> summarizes all info
    //$description_long = $database->getEscaped (JRequest::getVar('description_long', '', 'post', 'string', JREQUEST_ALLOWHTML ));    
    $description_long = "<p>{$description}</p><p>&nbsp;</p><p><strong><span style=\"color: #5a5a5a;\">Searched words:</span></strong> {$version}, {$author}, {$author_url}, {$description}</p>";
       
The <p>{$description}</p> is pure layout purpose. It is to make as if we have two variables displaying, the short description and then the searched words.
I have to admit plenty of fields were edited to use them without bothering creating custom fields. And do not forget to create yourself a backup to edit the next JD update easily!

And if you wonder, why we did not go for AceSearch, we simply hated it! The way results are displayed is a mess, and it costs a fortune to have the possibility to edit the CSS.




Offline Arno

  • Administrator
  • ***
  • Posts: 12.234
    • jDownloads.com
Re: Jdownloads_search code
« Reply #5 on: 28.02.2014 12:27:31 »
Hi Guys,
i have used for the new release 2.5 a modified version from the joomla core search function. So we will have in the future all what we need.
see screenshots in the main page article.

But thanks for your work.  ;)
« Last Edit: 28.02.2014 12:29:18 by Arno »
Best Regards / Gruß
Arno
Please make a Donation for jDownloads and/or write a review on the Joomla! Extensions directory!