Message
  • EU e-Privacy Directive

    This website uses cookies to manage authentication, navigation, and other functions. By using our website, you agree that we can place these types of cookies on your device.

    View Privacy Policy

Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Show results randomly?

Show results randomly? 7 years 7 months ago #1772

Hi,

searched for this and didn't find a post on it...

How can I make the results pages show by 'Random' as default?

I don't see a random option anywhere? If not random then by 'Least hits' ?


ScreenShot2014-04-02at09.55.45.png


Thanks.
The administrator has disabled public write access.

Show results randomly? 7 years 7 months ago #1773

  • andrea_4g
  • andrea_4g's Avatar
  • OFFLINE
  • Administrator
  • Posts: 1122
  • Thank you received: 163
There's not such an option, but...
it's fairly easy to implement.

Edit file components/com_customproperties/models/search.php
Change lines 572-576 from:
switch($ordering){
	case 'category' :
	...
to
$ordering = 'random';
switch($ordering){
	case 'random':
		$orderstr[] = 'RAND()';
		break;
	case 'category' :
	...

You also need to set parameter 'Section / Category ordering:' = None, in Custom Properties configuration.
The administrator has disabled public write access.

Show results randomly? 7 years 7 months ago #1774

Works great...

Except now the drop downs for 'Alphabetically' 'Newest' and 'oldest' etc also show randomly...
The administrator has disabled public write access.

Show results randomly? 7 years 7 months ago #1775

  • andrea_4g
  • andrea_4g's Avatar
  • OFFLINE
  • Administrator
  • Posts: 1122
  • Thank you received: 163
You can either:
- disable the Ordering dropdown (there's a set parameter in CP Config to modify the search header elements)
- keep on tweaking Custom Properties

If you choose the latter, here's what to do:

- edit components/com_customproperties/views/show/tmpl/default.php (**)
- change lines
from
$orders = array(
  JHTML::_('select.option', 'newest', JText::_('Newest First')),
  JHTML::_('select.option', 'oldest', JText::_('Oldest First')),
  JHTML::_('select.option', 'alpha',  JText::_('Alphabetical')),
  JHTML::_('select.option', 'ordering',  JText::_('Ordering')),
  JHTML::_('select.option', 'category', JText::_('Section/Category'))
);
to
$orders = array(
  JHTML::_('select.option', 'random', JText::_('Random')),
  JHTML::_('select.option', 'newest', JText::_('Newest First')),
  JHTML::_('select.option', 'oldest', JText::_('Oldest First')),
  JHTML::_('select.option', 'alpha',  JText::_('Alphabetical')),
  JHTML::_('select.option', 'ordering',  JText::_('Ordering')),
  JHTML::_('select.option', 'category', JText::_('Section/Category'))
);

(**) or write your own override, based of default.php
The administrator has disabled public write access.

Show results randomly? 7 years 7 months ago #1776

Sorry for all the questions...

I added that code and it is now available in the drop down...

ScreenShot2014-04-02at14.01.20.png


However, if a user selects 'alphabetically' it still shows them randomly...

ScreenShot2014-04-02at13.59.25.png


So now every option is random... :(
The administrator has disabled public write access.

Show results randomly? 7 years 7 months ago #1777

  • andrea_4g
  • andrea_4g's Avatar
  • OFFLINE
  • Administrator
  • Posts: 1122
  • Thank you received: 163
True that.

You need to undo the modifications in search.php I previously suggested, and apply the following.
Change line 599
from
case 'newest':
default:
	$orderstr[] = "c.".$ce->created." DESC";
	break;
to
case 'newest':
	$orderstr[] = "c.".$ce->created." DESC";
	break;
case 'random':
default:
	$orderstr[] = 'RAND()';
	break;

You also need to set 'Default results ordering' = None, in Custom Properties config.
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Time to create page: 0.182 seconds