![]() |
|
|
Welcome to the { mindfrost82.com } forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Seeking a "Text/Quote Randomizer" Script (nothing fancy)
I'm looking for a "text randomizer" script.
There's a div in my layout that should be pulling up different content (randomly) each time the page reloads. Ideally, I'll like to stay away from databases and just use a text file. The way I'm envisioning it, there would be a different text on each line. All the script would have to do is randomly choose which line to pull text from and display it in the layout at the appropriate location. The layout is liquid, and will adapt to any amount of text pulled. The text should be treated like a normal include. In other words, HTML and CSS tags would work. I'm open to a PHP-based solution, even if I'm no PHP programmer. Thanks! |
|
|||
|
Re: Seeking a "Text/Quote Randomizer" Script (nothing fancy)
Can you use legacy .ASP? If so there's an object called "ContentRotator"
that would do exactly what you want. I used it once a while ago, so if you can use ASP I'll dig it up and pass it on as an example for you. -- Chris Leeds Contact: http://chrisleeds.com/contact Have you seen ContentSeed (www.contentseed.com)? NOTE: This message was posted from an unmonitored email account. This is an unfortunate necessity due to high volumes of spam sent to email addresses in public newsgroups. Sorry for any inconvenience. "mjs" <no@thanks.com> wrote in message news:g7a7qa$94m$1@forums.macromedia.com... > I'm looking for a "text randomizer" script. > > There's a div in my layout that should be pulling up different content > (randomly) each time the page reloads. Ideally, I'll like to stay away > from databases and just use a text file. The way I'm envisioning it, there > would be a different text on each line. All the script would have to do is > randomly choose which line to pull text from and display it in the layout > at the appropriate location. The layout is liquid, and will adapt to any > amount of text pulled. > > The text should be treated like a normal include. In other words, HTML and > CSS tags would work. > > I'm open to a PHP-based solution, even if I'm no PHP programmer. > > Thanks! > |
|
|||
|
Re: Seeking a "Text/Quote Randomizer" Script (nothing fancy)
you could also use the rand() function in php if that's your server language
mjs skrev: > I'm looking for a "text randomizer" script. > > There's a div in my layout that should be pulling up different content > (randomly) each time the page reloads. Ideally, I'll like to stay away from > databases and just use a text file. The way I'm envisioning it, there would > be a different text on each line. All the script would have to do is > randomly choose which line to pull text from and display it in the layout at > the appropriate location. The layout is liquid, and will adapt to any amount > of text pulled. > > The text should be treated like a normal include. In other words, HTML and > CSS tags would work. > > I'm open to a PHP-based solution, even if I'm no PHP programmer. > > Thanks! > > > -- Kim --------------------------- http://www.geekministry.com |
|
|||
|
Re: Seeking a "Text/Quote Randomizer" Script (nothing fancy)
This one uses JavaScript and an array of text/quotes inside your page. No
databases required. http://www.codelifter.com/main/javas...domquote.shtml --Nancy O. Alt-Web Design & Publishing www.alt-web.com "mjs" <no@thanks.com> wrote in message news:g7a7qa$94m$1@forums.macromedia.com... > I'm looking for a "text randomizer" script. > > There's a div in my layout that should be pulling up different content > (randomly) each time the page reloads. Ideally, I'll like to stay away from > databases and just use a text file. The way I'm envisioning it, there would > be a different text on each line. All the script would have to do is > randomly choose which line to pull text from and display it in the layout at > the appropriate location. The layout is liquid, and will adapt to any amount > of text pulled. > > The text should be treated like a normal include. In other words, HTML and > CSS tags would work. > > I'm open to a PHP-based solution, even if I'm no PHP programmer. > > Thanks! > > |
|
|||
|
Re: Seeking a "Text/Quote Randomizer" Script (nothing fancy)
"Chris Leeds, MVP - FrontPage" <NewsGroups@ChrisLeeds.com> wrote in message
news:g7a8jt$a3l$1@forums.macromedia.com... > Can you use legacy .ASP? If so there's an object called "ContentRotator" > that would do exactly what you want. > I used it once a while ago, so if you can use ASP I'll dig it up and pass > it on as an example for you. Not sure, but I'm a bit scared of the expression "Legacy" :-) I use DreamHost. I'm assuming you're familiar enough with it to know whether they carry legacy ASP or not (or I can ask them, but it'll take a day or two for an answer). As you can see, I'm totally unfamiliar with ASP. |
|
|||
|
Re: Seeking a "Text/Quote Randomizer" Script (nothing fancy)
Is it one or the other? Because I know it uses PHP (I use PHP includes here
and there). If that means no ASP, then I've got no ASP. :-) Could you give me a working example of how the function you suggest works? "kim" <kim@removegeekministry.com> wrote in message news:g7aa9k$bqd$1@forums.macromedia.com... > you could also use the rand() function in php if that's your server > language |
|
|||
|
Re: Seeking a "Text/Quote Randomizer" Script (nothing fancy)
On 05 Aug 2008 in macromedia.dreamweaver, mjs wrote:
> I'm looking for a "text randomizer" script. > > There's a div in my layout that should be pulling up different > content (randomly) each time the page reloads. Ideally, I'll like to > stay away from databases and just use a text file. The way I'm > envisioning it, there would be a different text on each line. All > the script would have to do is randomly choose which line to pull > text from and display it in the layout at the appropriate location. > The layout is liquid, and will adapt to any amount of text pulled. > > The text should be treated like a normal include. In other words, > HTML and CSS tags would work. > > I'm open to a PHP-based solution, even if I'm no PHP programmer. Here's a quick-and-dirty I did a while back: <?php $quotesArray = file('quotes.txt'); $numQuotes = count($quotesArray); // Get the number of quotes N $quote1 = rand(0,$numQuotes-1); // Want a random number between 0 and N-1 ?> <blockquote><?php echo $quotesArray[$quote1]; ?></blockquote> This assumes a flat textfile named quotes.txt, in the same directory as the page, with one quote per line. If the quotes have linebreaks in them, the script thinks that they're separate quotes. -- Joe Makowiec http://makowiec.net/ Email: http://makowiec.net/contact.php |
|
|||
|
Re: Seeking a "Text/Quote Randomizer" Script (nothing fancy)
"Joe Makowiec" <makowiec@invalid.invalid> wrote in message
news:Xns9AF1ACB62A946makowiecatnycapdotrE@216.104. 212.96... > > Here's a quick-and-dirty I did a while back: > > <?php > $quotesArray = file('quotes.txt'); > $numQuotes = count($quotesArray); // Get the number of quotes N > $quote1 = rand(0,$numQuotes-1); // Want a random number between 0 and N-1 > ?> > <blockquote><?php echo $quotesArray[$quote1]; ?></blockquote> > > This assumes a flat textfile named quotes.txt, in the same directory as > the page, with one quote per line. If the quotes have linebreaks in > them, the script thinks that they're separate quotes. Awesome. Could it parse HTML code? I mean, would it know what to do with a line like : <span class="quote">Hello<br><a href="#">test</a></span> ...? |
|
|||
|
Re: Seeking a "Text/Quote Randomizer" Script (nothing fancy)
On 06 Aug 2008 in macromedia.dreamweaver, mjs wrote:
> "Joe Makowiec" <makowiec@invalid.invalid> wrote in message > news:Xns9AF1ACB62A946makowiecatnycapdotrE@216.104. 212.96... >> >> Here's a quick-and-dirty I did a while back: >> >> <?php >> $quotesArray = file('quotes.txt'); >> $numQuotes = count($quotesArray); // Get the number of quotes N >> $quote1 = rand(0,$numQuotes-1); // Want a random number between 0 >> and N-1 ?> <blockquote><?php echo $quotesArray[$quote1]; >> ?></blockquote> >> >> This assumes a flat textfile named quotes.txt, in the same >> directory as the page, with one quote per line. If the quotes have >> linebreaks in them, the script thinks that they're separate quotes. > > Awesome. Could it parse HTML code? I mean, would it know what to do > with a line like : > > <span class="quote">Hello<br><a href="#">test</a></span> > > ..? It doesn't care; it doesn't parse anything. I haven't tried it out with UTF-8 charsets, but other than that, if you can put something into a plain text file, the script as given will deal with it. The only caveat I'd make is that making the code you include in the text file work in context is left to you, the developer. If your container is, say, a paragraph <p></p> rather than blockquote as above, then you probably don't want to include headline tags <h2></h2> in the quote you're importing. -- Joe Makowiec http://makowiec.net/ Email: http://makowiec.net/contact.php |
|
|||
|
Re: Seeking a "Text/Quote Randomizer" Script (nothing fancy)
"Joe Makowiec" <makowiec@invalid.invalid> wrote in message
news:Xns9AF27D6C38596makowiecatnycapdotrE@216.104. 212.96... > > This assumes a flat textfile named quotes.txt, in the same > directory as the page, with one quote per line. If the quotes have > linebreaks in them, the script thinks that they're separate quotes. > > The only caveat I'd make is that making the code you include in the > text file work in context is left to you, the developer. If your > container is, say, a paragraph <p></p> rather than blockquote as above, > then you probably don't want to include headline tags <h2></h2> in the > quote you're importing. Then I'm assuming it doesn't consider <br> a line break, since it's not parsing anything. Nothing short of an actual unicode linebreak mark the end of a quote, right? (Or I could just test it... which I will do right now.) :-) |
![]() |
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|