Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,059 of 9,059 pages
About the help in other languages
All help pages

Titel: Zufallsoperator für Templates

Ein neuer Template-Operator erzeugt Zufallszahlen. Er gibt eine Ganzzahl zurück, auf Wunsch aus einem angegebenen Bereich.

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/features/3.8/template_rand_function.txt

This page is a translation. Read the English original

*Titel: Zufallsoperator für Templates

*Beschreibung:
Ein neuer Template-Operator erzeugt Zufallszahlen. Er gibt eine Ganzzahl zurück, auf Wunsch aus
einem angegebenen Bereich.

*Dokumentation:

Einen Zufallswert erzeugen. Die Eingabeparameter sind optional.

rand( [min_val, max_val] )

Rückgabe:
Eine zufällige Ganzzahl. Sind Eingabeparameter angegeben, liegt sie zwischen min_val und max_val.

Parameter:
'min_val' - kleinster Ganzzahlwert
'max_val' - größter Ganzzahlwert

Beispiel:
Einen zufälligen Artikel unter '/news' (Knoten 102) abrufen.

{def $news_count = fetch( content, list_count, hash( 'parent_node_id', 102,
                                                     'class_filter_type',  'include',
                                                     'class_filter_array', array( 'article' ) ) )
     $news_article = fetch( 'content','list',
                            hash( 'parent_node_id', 102,
                                  'class_filter_type', 'include',
                                  'class_filter_array', array( 'article' ),
                                  'limit', 1,
                                  'offset', rand(1, $news_count )|sub(1) ) )}


Something wrong on this page? Report an error

Documentation license

This page was inherited from the documentation of the original software. It is not covered by the GNU Free Documentation License; it is distributed under the GNU General Public License, version 2.

Copyright (C) 1999 - 2014 eZ Systems AS and contributors