Show results randomly?

  • crashtackle
  • Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 8 months ago #1772 by crashtackle
Show results randomly? was created by crashtackle
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' ?




Thanks.
Attachments:

Please Log in or Create an account to join the conversation.

More
10 years 8 months ago #1773 by andrea_4g
Replied by andrea_4g on topic Show results randomly?
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:
Code:
switch($ordering){ case 'category' : ...
to
Code:
$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.

Please Log in or Create an account to join the conversation.

  • crashtackle
  • Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 8 months ago #1774 by crashtackle
Replied by crashtackle on topic Show results randomly?
Works great...

Except now the drop downs for 'Alphabetically' 'Newest' and 'oldest' etc also show randomly...

Please Log in or Create an account to join the conversation.

More
10 years 8 months ago #1775 by andrea_4g
Replied by andrea_4g on topic Show results randomly?
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
Code:
$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
Code:
$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

Please Log in or Create an account to join the conversation.

  • crashtackle
  • Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 8 months ago #1776 by crashtackle
Replied by crashtackle on topic Show results randomly?
Sorry for all the questions...

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



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



So now every option is random... :(
Attachments:

Please Log in or Create an account to join the conversation.

More
10 years 8 months ago #1777 by andrea_4g
Replied by andrea_4g on topic Show results randomly?
True that.

You need to undo the modifications in search.php I previously suggested, and apply the following.
Change line 599
from
Code:
case 'newest': default: $orderstr[] = "c.".$ce->created." DESC"; break;
to
Code:
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.

Please Log in or Create an account to join the conversation.

Time to create page: 0.187 seconds