Zum Inhalt springen

orderBy = RAND() TYPO3 8.7

Erstellt am 5. Mai 2017 · 3 Antworten · letzte Antwort am 13. Oktober 2017

Tags: Datenbank, TYPO3 8, Frage

thowe ·

Hallo liebe Foristi

möchte von einem bestimmten SysFolder (id=23) zufälligen INhalt aus der Spalte normal (colPos=0) ausgeben.

Folgendes TS-Snippet

lib.randomRatings = COA_INT
lib.randomRatings {
  10 = CONTENT
  10 {
    table = tt_content
    select {
      pidInList = 23
      where = colPos = 0
      orderBy = RAND()
      max = 2
      languageField = sys_language_uid
    }
    renderObj < tt_content
    renderObj.stdWrap.wrap = <div class="randomRatings">|</div>
    renderObj.stdWrap.required = 1
  }
}

führt zu folgedner Fehlermeldung:

Ooops an Error occured (...)
(...) unknown column RAND() (...)

Hat jemand eine Idee, wie man einen zufälligen Inhalt aus der Spalte tt_content generieren kann?

thowe ·

Hallo,

hat wirklich niemand eine Lösung, oder zumindest einen Ansatz, eine Anregung, eine Idee...?

seebold ·

Ich stehe vor dem selben Problem und würde mich freuen, wenn jemand eine Lösung weiß.

Liebe Grüße
Martin

stosef ·

Hi,
meine Lösung:

block.teaser = COA_INT
block.teaser {
    10 = CONTENT
    10 {
        table = tt_content
        select {

            selectFields = *, rand() as virt_rnd

            # UID of the page with the content elements
            pidInList = 1
            where = colPos=1

            # amount of content elements to find
            max = 4

            # randomize
            orderBy = virt_rnd

            # constrain by language
            languageField = sys_language_uid
        }
    }
}