2

I search a way to randomize the order of tx_news article.

Is it possible without changing the NewsRepository.php?

If not, what would be the best way to add a random order?

nbar
  • 6,028
  • 2
  • 24
  • 65
  • did you ever find a solution ? – webman Feb 11 '17 at 07:25
  • @webMan iirc I used a random offset and requested then 20 news in a row, but from a random offset. So maybe I got article 180 to 200. And another time I got article 45 to 65. For what I needed this was enough. If you want more randomness you would need to edit the news extension. – nbar Feb 14 '17 at 16:05

1 Answers1

0

News hasn't such possibility in its repository.

Assuming that you most probably want to use random order per each page view... I'd suggest to use ... JavaScript. Otherwise you will need to use non-cached content or page, which will influence your performance.

Of course you can create custom extension in which you'll be able to extend the repository class to add missing methods and render in your template, anyway in this case I also suggest supporting it with JS for better performance.

biesior
  • 55,576
  • 10
  • 125
  • 182
  • Order the displayed articles with JS would not be the problem. But I have like 2000 article and need 20 random article out of them. And I can't load 2000 articles (with all the images). They don't need to be completly random, it would also be possible to get 20 article in a row but starting at a random point (for example artile 200 to 220) – nbar Feb 04 '15 at 01:00
  • Indeed, with these numbers pure JS is not an option, you need to create custom extension for it, which will select random records and render the list with it. – biesior Feb 04 '15 at 10:16