Random Blocks of Text?
Random Blocks of Text?
I don't know if this is even possible. In the same way that {RANDOM} randomly selects and displays an image, is it possible to randomly select and display a block of text? I guess this would be semi-dynamic content.
Don Bledsoe
FOREFRONT INTERNET
FOREFRONT INTERNET
- Oliver Georgi
- Site Admin
- Posts: 9918
- Joined: Fri 3. Oct 2003, 22:22
- Contact:
Oliver Georgi wrote: I will implement such random feature in it.
Oliver
Ich weiss nicht ob schon getan aber nicht dokumentiert...
Für alle PHP-Learning-By-Doing-Fussgänger wie mich hier mal ein Beispiel:
[PHP]
// Ein Array basteln, mit den
// ContentPart-IDs, die als
// Pool für die per Zufall
// auszuwählenden dienen sollen
// In diesem Fall 6 Stück
$a=array(385,387,388,389,390,391);
// Das Ganze durch den Mixer jagen
shuffle($a);
// Aus den neu geordneten IDs von vorn
// beginnend welche herauspicken (PHP-Lotto)
// In diesem Fall 3 Stück
$rand1=$a[0];
$rand2=$a[1];
$rand3=$a[2];
// Und jetzt anzeigen lassen
echo '{SHOW_CONTENT:CP,'; print_r($rand1); echo ','; print_r($rand2); echo ','; print_r($rand3); echo '}';
[/PHP]
intentionally left blank
- Oliver Georgi
- Site Admin
- Posts: 9918
- Joined: Fri 3. Oct 2003, 22:22
- Contact:
Code: Select all
[PHP]
$a = array(385,387,388,389,390,391);
shuffle( $a );
echo '{SHOW_CONTENT:CP,' . $a[0] . ',' . $a[1] . ',' . $a[2] . '}';
[/PHP]
Oliver
if the cp´s are in a continuously order, (i had 75 cp´s with quotations)
i dissolved this prob with the command 'rand' ...
dazu noch was:
wenn die cp´s in fortlaufender reihenfolge sind (ich hatte zb 75 cp´s
mit zitaten) - dann habe ich einfach ein random mit den cp "von bis"
erstellt.
and again a line saved ...
und wieder eine zeile gespart ...
i dissolved this prob with the command 'rand' ...
dazu noch was:
wenn die cp´s in fortlaufender reihenfolge sind (ich hatte zb 75 cp´s
mit zitaten) - dann habe ich einfach ein random mit den cp "von bis"
erstellt.
Code: Select all
[PHP]
$z = rand(286,300); // von cp 286 bis cp 300
echo '{SHOW_CONTENT:CP,' . $z . ',}';
[/PHP]
und wieder eine zeile gespart ...
ja sicher läuft das - einfach hier gucken - rechts die zitate kommen bei jedem aktualiseren als random ... demo
(look at the demo - it runs !)
und sieht so aus (ich habs in die vorlage gepackt, weils auf jeder seite erscheinen soll) -
(i´ve written the code in the template - here it is:)
wichtig ist nur dass die Artikel ID´s fortlaufend sind !
all articel id will be serially numbered ...
to all - please talk english (or both)
[/color]
(look at the demo - it runs !)
und sieht so aus (ich habs in die vorlage gepackt, weils auf jeder seite erscheinen soll) -
(i´ve written the code in the template - here it is:)
Code: Select all
<div id="rechts"><div id="zitate">ZITATE:
[PHP]
$z = rand(300,374); //test
echo '{SHOW_CONTENT:CP,' . $z . ',}';
[/PHP]
</div>
{RIGHT}
</div>
all articel id will be serially numbered ...
to all - please talk english (or both)
[/color]
Hi all
You might want to look at this:-
http://www.phpwcms.de/forum/viewtopic.p ... r&start=60
works very nicely and you dont need the sequential ID nums!
You might want to look at this:-
http://www.phpwcms.de/forum/viewtopic.p ... r&start=60
works very nicely and you dont need the sequential ID nums!