0

In a v12 TYPO3 site running EXT:news 12.3.0 I'd like to display a random selection of news articles, maintaining other chosen restraints (as limit to categories, respect top news etc.).

Best practice would add the item random to $GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['orderByNews'] and adapt the demand accordingly. (I'd rather not resort to fetching all articles and then have a viewhelper do the math)

Adding the item is explained here in the documentation.

Anyone knows how to script the rest ? (or a tutorial that would explain how to go about)

1 Answer 1

0

Unfortunately this cannot be achieved currently. News uses the regular Extbase persistence internally and only makes the order selection configurable.

Extbase does not support SQL options like random sorting.

So you may indeed need to fetch a sufficient amount of items and then shuffle them at runtime / on render. It may be more performant to first fetch all relevant UIDs first and shuffle these. Then, after applying a limit, you can fetch a vastly reduced but now shuffeld subset of news objects.

Sign up to request clarification or add additional context in comments.

1 Comment

did you consider accessing the news table directly with typoscript and a databaseprocessor with orderBy = rand() ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.