Altering the ordering of search results

For Joomla! 1.0 Coding related discussions.
Locked
halobay
Joomla! Intern
Joomla! Intern
Posts: 94
Joined: Thu Oct 13, 2005 3:19 pm

Altering the ordering of search results

Post by halobay » Fri Nov 25, 2005 5:43 pm

Hello

Is there anyway to have as default the search results to be ordered from the most popular to the less popular, instead of the default way which is the newese first, the oldest at the end.

What I have to change in order to achieve this?

Thanks in advance

User avatar
Tonie
Joomla! Master
Joomla! Master
Posts: 16553
Joined: Thu Aug 18, 2005 7:13 am

Re: Altering the ordering of search results

Post by Tonie » Fri Nov 25, 2005 6:12 pm

This is probably it:
line 93 of search.php

Code: Select all

$ordering = mosGetParam( $_REQUEST, 'ordering', 'popular');
line 125 of search.html.php

Code: Select all

$ordering = trim( strtolower( mosGetParam( $_REQUEST, 'ordering', 'popular' ) ) );
line 216 of search.html.php

Code: Select all

$ordering = trim( strtolower( mosGetParam( $_REQUEST, 'ordering', 'popular' ) ) );

halobay
Joomla! Intern
Joomla! Intern
Posts: 94
Joined: Thu Oct 13, 2005 3:19 pm

Re: Altering the ordering of search results

Post by halobay » Fri Nov 25, 2005 8:33 pm

Thank you very much for your help.

This work very good if someone clicks on a menu link which is pointing to the search component. If someone uses the search module, or a search box, takes as result a list with the newest articles first. Is there a way in order to make the search results which are coming from the search module, or a search box, to order with the most populars first.

Thanks againfor your valuable help

User avatar
Tonie
Joomla! Master
Joomla! Master
Posts: 16553
Joined: Thu Aug 18, 2005 7:13 am

Re: Altering the ordering of search results

Post by Tonie » Fri Nov 25, 2005 9:29 pm

Sorry, can't find this anytime soon. Getting late for me :).

halobay
Joomla! Intern
Joomla! Intern
Posts: 94
Joined: Thu Oct 13, 2005 3:19 pm

Re: Altering the ordering of search results

Post by halobay » Sat Nov 26, 2005 5:56 am

Tonie thank you for your answers. If you find some time and if it is not very much trouble for you, could you find what is going on with this issue? I thought that by changing the searcg component files also the results which you are getting form search module should follow the same logic.

Thanks again

dmcghan
Joomla! Apprentice
Joomla! Apprentice
Posts: 26
Joined: Mon Nov 07, 2005 10:49 pm
Location: Clearwater, FL - USA
Contact:

Re: Altering the ordering of search results

Post by dmcghan » Fri Dec 02, 2005 11:37 pm

I hear you halobay. I'm having the same problem.

I'm going to spend some time looking into this over the weekend. I'll let you know what I find. If you or anyone else figures this one out first, please let us know!

halobay
Joomla! Intern
Joomla! Intern
Posts: 94
Joined: Thu Oct 13, 2005 3:19 pm

Re: Altering the ordering of search results

Post by halobay » Sun Dec 04, 2005 8:50 am

If you find something let me know  :) I am searching for this hack for ages  :D

halobay
Joomla! Intern
Joomla! Intern
Posts: 94
Joined: Thu Oct 13, 2005 3:19 pm

Re: Altering the ordering of search results

Post by halobay » Wed Dec 07, 2005 2:01 pm

Hey dmcghan any luck with this?

User avatar
Tonie
Joomla! Master
Joomla! Master
Posts: 16553
Joined: Thu Aug 18, 2005 7:13 am

Re: Altering the ordering of search results

Post by Tonie » Wed Dec 07, 2005 2:10 pm

As it seems that quite a lot of people want this feature, I will put up a post in the wishlist/request forum.

edits1
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Fri Oct 02, 2009 7:41 pm

Re: Altering the ordering of search results

Post by edits1 » Wed Dec 08, 2010 1:43 am

Hello,

I've browsed the forum on this topic pretty well, and don't see a method for changing the order of search results using either a plugin, or a PHP code modification in cases where another component, such as ajaxSearch, is running as a supplement to the component_search module.

Has anyone solved this for v1.5 native?

I'm trying to get ajaxSearch to run in conjunction with my component_search module so that 'most popular' is the default setting in both (i.e. it's a parameter setting in ajaxSearch, so that's great for the ajax generated list, but the PHP change (outlined below) for the default component will not work if ajaxSearch is enabled).

Change the order of the dropdown list in the file: view.html.php

Lines 72-77 should read:
$orders = array();
$orders[] = JHTML::_('select.option', 'popular', JText::_( 'Most popular' ) );
$orders[] = JHTML::_('select.option', 'newest', JText::_( 'Newest first' ) );
$orders[] = JHTML::_('select.option', 'oldest', JText::_( 'Oldest first' ) );
$orders[] = JHTML::_('select.option', 'alpha', JText::_( 'Alphabetical' ) );
$orders[] = JHTML::_('select.option', 'category', JText::_( 'Section/Category' ) );

I messed around with the controller.php and search.php files as well. The above change was all it took.

Thanks!


Locked

Return to “Joomla! 1.0 Coding”