Zum Inhalt springen

Random content without extension with TypoScript

There are extensions to display random content on the page. It is easier if you add another selection to the Special menus content element.

Attention: the TypoScript only works when using css_styled_content, but no longer under TYPO3 >= 7.6, if fluid_styled_content is used.

The editor only has to select a page with content in the standard content elements and does not have to insert a plugin.

The following TypoScript adds another element:

tt_content.menu.20.8 = COA_INT
tt_content.menu.20.8 {
  10 = CONTENT
  10 {
    table = tt_content
    select {
      pidInList.override.field = pages
      where = colPos=0
      max = 1
      orderBy = rand()
    }
  }
}

For the content elements that are to be output, make sure that the column is specified correctly:
where = colPos=0

To make the new field appear in the backend, enter the following in PageTSconfig:

TCEFORM.tt_content.menu_type.addItems.8 = Random content from selected page

A further selection option is then available in the "Special menus" content element.

The following code can also be used for the random output of header images or similar (thanks to Jigal von Hemert for the tip):

stdWrap.listNum = rand

This page contains automatically translated content.

Updated: 09.04.2025