Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2007-06-22 18:30:41
- WhiteDog
- Member
- From: Maine
- Registered: 2005-09-07
- Posts: 174
Request for Random Quote plug-in
I spent some time searching for a random quote plug-in but could not find one. So I thought perhaps someone here could develop one.
I found this PHP script by Steve Dawson
<?php
## The name of the .txt file which hold the rotating info (currently random.txt)
$filename = “random.txt”;
$file = file($filename);
## This prints the banner, quotes or random text, or whatever is in the random.txt file
print “$RandomRotator”;
?>
this does what I am looking for but I’d love it if you could update to it with news articles and have as a plug-in.
Thanks to any one who reads this.
Grrr RRR nnndth grrr Skeek!
Offline
#2 2007-06-22 18:40:28
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Request for Random Quote plug-in
There is a plugin: dru_random_text that I used to use to do exactly that, but it’s old and I don’t know if it still works in 4.0.4. But you can do the same thing easily with <txp:article_custom sort="rand()" />
.
Offline
Re: Request for Random Quote plug-in
Els wrote:
There is a plugin: dru_random_text that I used to use to do exactly that, but it’s old and I don’t know if it still works in 4.0.4.
It’s still working for me in 4.0.4.
TextPattern user since 04/04/04
Offline
#4 2007-06-22 19:28:46
- WhiteDog
- Member
- From: Maine
- Registered: 2005-09-07
- Posts: 174
Re: Request for Random Quote plug-in
thank you very much :D
Grrr RRR nnndth grrr Skeek!
Offline
Re: Request for Random Quote plug-in
For large numbers of rows/entries/articles, sort="rand()"
or the SQL equivalent ORDER BY RAND()
will be slow, but there are ways to get the same result much faster, using 2 queries: see the last comment by Colin Guthrie on this page
For dru_random_text, that would mean changing:
$sql = "select $column from $table order by rand() limit 1";
into something like this (not tested):
$sql = "select $column from $table limit ".floor(mt_rand(0,getThing("select $column from $table")-1)).",1";
Last edited by ruud (2007-06-22 19:39:34)
Offline
Re: Request for Random Quote plug-in
I show random quotes on my site (at the bottom) by posting all the quotes as articles in a special ‘quotes’ section, and then using this:
<txp:article_custom section="quotes" form="quote_footer" limit="1" sortby="rand()" />
Last edited by truist (2008-07-03 11:40:48)
Offline
Re: Request for Random Quote plug-in
Quite old this.
Does anyone know if it’s working in 4.05?
Offline
Re: Request for Random Quote plug-in
If it’s working in 4.0.4, then it should work fine in 4.0.5
Offline