Show results randomly?

  • crashtackle
  • Autore della discussione
  • Offline
  • Nuovo Utente
  • Nuovo Utente
Di più
9 Anni 11 Mesi fa #1772 da crashtackle
Show results randomly? è stato creato da 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.
Allegati:

Si prega Accesso o Crea un account a partecipare alla conversazione.

Di più
9 Anni 11 Mesi fa #1773 da andrea_4g
Risposta da andrea_4g al 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.

Si prega Accesso o Crea un account a partecipare alla conversazione.

  • crashtackle
  • Autore della discussione
  • Offline
  • Nuovo Utente
  • Nuovo Utente
Di più
9 Anni 11 Mesi fa #1774 da crashtackle
Risposta da crashtackle al topic Show results randomly?
Works great...

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

Si prega Accesso o Crea un account a partecipare alla conversazione.

Di più
9 Anni 11 Mesi fa #1775 da andrea_4g
Risposta da andrea_4g al 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

Si prega Accesso o Crea un account a partecipare alla conversazione.

  • crashtackle
  • Autore della discussione
  • Offline
  • Nuovo Utente
  • Nuovo Utente
Di più
9 Anni 11 Mesi fa #1776 da crashtackle
Risposta da crashtackle al 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... :(
Allegati:

Si prega Accesso o Crea un account a partecipare alla conversazione.

Di più
9 Anni 11 Mesi fa #1777 da andrea_4g
Risposta da andrea_4g al 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.

Si prega Accesso o Crea un account a partecipare alla conversazione.

Tempo creazione pagina: 0.149 secondi