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!

On 06 Aug 2008 in macromedia.dreamweaver, mjs wrote:
> "Joe Makowiec" <[email protected]> wrote in
message
>
news:[email protected]..
>>
>> 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

Similar Messages

  • How to use the text module in script

    hi,
            i script how to use the text modules and how to write the code  in layout of the script?

    Hi,
    You canr use text modules in script. You have to use standard texts .
    Standard text are maintained in SO10 transaction.
    you can create translation text for other languages also . So based on logon language it will print translation text.
    go to SO10
    give textname it say Ztextname  id as ST and language as EN
    say create, then you will get editor there maintain your text and save it . then come back . Now change language (say for german DE) say create and eneter translation text and save it.
    so now you have created a text called ztextname which you can use in your script.
    Inorder to insert the texts in your script do as below
    go to any window editor and   select path
    Insert->texts->symbols->standard symbols
    then you will get popup  in which you have to mention all the parameters that you have created earlier.
    after inserting just change language EN to sy-langu
    Reward points if useful
    About text elements Sravan already given some informatiomn
    Regards,
    Nageswar

  • How to color the text  elements in script?

    how to color the text  elements in script?
    byeeeee
    plz send the answers

    Hi,
    Please go through my blog to know how to do color printing in SAP scripts.
    White Paper on 'Color Printing in SAP Scripts'
    Regards,
    Sireesha Ch

  • How to call text file using Script in Data Integrator

    Dear All,
    Can any one assit me in how to call a text file using script with the help of Data Integrator.
    and one question ?
    M having 32 csv files i want to club thos 32 csv files into one table with the help of Data Integrator, can
    any one assist me.

    mary,
    since you knew the file name ,when clicked in name send to server,read the file and write to servlet outputstream.
    I think this would help you.
    If anything wrong in mycode ..forums will help you further
    BufferedInputStream bis=null;
    BufferedOutputStream bos=null;
    int bytesRead=0;
    byte buff[]=new byte[1024];
    File f=new File(test.txt);
    try{
         bis= new BufferedInputStream(new FileInputStream(f));
         bytesRead=bis.read(buff,0,buff.length);
         if(bytesRead!=-1){
              // create a BufferedOutputStream from ServletOutputStream
              bos=new BufferedInputStream(response.getOutputStream());
              do{
                   bos.write(buff,0,bytesRead);
              }while((bytesRead=bis.read(buff,0,buff.length))!=-1)
    }catch(Exception e){
         ////error handling
         }

  • When I run this script nothing is output to the screen or spooled to a file

    When I run this script nothing is output to the screen or spooled to a file. What do I need to do to get output from this script.
    SET SERVEROUTPUT ON size 100000
    DECLARE
    v_schema     Varchar2(50);
    v_statement      Varchar2(500);
    v_name varchar2(30);
    v_id varchar2(8);
    v_pwd varchar2(16);
    v_acct varchar2(16);
    CURSOR get_schemas IS
    SELECT DISTINCT owner
    FROM all_tables
    WHERE table_name = 'USERID'
    ORDER BY owner;
    BEGIN
    OPEN get_schemas;
    LOOP
    FETCH get_schemas INTO v_schema;
    EXIT WHEN get_schemas%NOTFOUND;
              v_statement := 'SELECT name,usid,passwd,acctnum INTO v_name,v_id,v_pwd,v_acct FROM '||v_schema||'.userid';
              execute immediate v_statement;
              DBMS_OUTPUT.PUT_LINE('Name='||v_name||' ID='||v_id||' PW='||v_pwd||' AC='||v_acct);          
    END LOOP;
    CLOSE get_schemas;
    END;
    /

    Do I include several variables after the INTO or just
    one?
    How do I loop through the record and print the
    individual variables?
    I appreciate your assistance!He already gave you the answer above:
    v_statement := 'SELECT name,usid,passwd,acctnum FROM ' || v_schema ||
    '.userid';
    execute immediate v_statement
    INTO v_name, v_id, v_pwd, v_acct;
    If this is not printing any output, it is because you don't have a table named USERID... what are you trying to do?

  • Standard text in SAP Script

    Hi All,
      I am Creating Standard text in SAP Script. I want to Transport it to Quality and Production servers.But while saving standard text it is not asking transport request no.weather we need to create the text seperately in quality and in production or we can attach it in to transport request. Please suggest me.
    Thanks and Regards
    Partha.

    Hi partha,
    1. We can use the standard program
       RSTXTRAN
    2. It is meant specially for this purpose only.
    (we can attach standard text to a transport request)
    regards,
    amit m.

  • Problem in using standard text in SAP Script

    Hi All,
    I have to replace English text hardcoded in a script with standard texts (SO10) in Spanish. When I am including the standard text in script, it is displayed in different font and bigger size. I want to reduce the size and change the font of standard text. Is there any way to do that?
    Thanks in advance
    Radhika
    <MOVED BY MODERATOR TO THE CORRECT FORUM>
    Edited by: Alvaro Tejada Galindo on Jan 4, 2010 2:37 PM

    Please check the links below , which might hel you..
    Re: Setting font to standard text in sap script
    How to change stranded text font in script
    Regards
    Satish Boguda

  • How to provide space and new line to the text in AI Script

    how to provide space and new line to the text in AI Script

    ?? can you explain better, can you at least add another sentence?
    space
    var mySpace = " ";
    new line
    var newLine = "\n";

  • When I copy and paste text in facebook, the text looks fine until I hit 'share' or 'comment' to submit it. Firefox then adds indiscriminate line-feeds within the text and it looks nothing like the original text. This does not happen in Safari. (Mac OSX 10

    When I copy and paste text in facebook, the text looks fine until I hit 'share' or 'comment' to submit it. Firefox then adds indiscriminate line-feeds within the text and it looks nothing like the original text. It makes it very difficult to read and awful to look at.
    This does not happen in Safari.
    (Mac OSX 10.6.4 with Firefox 3.6.6).
    == URL of affected sites ==
    http://

    Same problem, 3.6.8 and previous recent versions. I never thought to try another browser but I just pasted into IE and it worked fine. I copied from Firefox to IE and it worked as well. It's just when you paste into Firefox that you get the weird line breaks.

  • Problem in long text in SAP script editor

    Hi ,
    i am maintaining long text in SAP script editor , when i am trying to change the long text in SAP script that changes are not reflected in print preview ,for example when i am giving tabs in the script then in print preview of the PO these tabs are displayed as , , ( comma) , and underlines are not appearing in print preview.please help me on this.
    Thanks and regards.
    Rajeshwar.

    hi
    you have to install the correct printer which supports the displaying the drawings and objects/

  • PO for item of service Level short and long text using sap script

    Please let me know how to do the PO for item of service Level short and long text using sap script.
    <MOVED BY MODERATOR TO THE CORRECT FORUM>
    Edited by: Alvaro Tejada Galindo on May 5, 2009 10:25 AM

    Hi ,
          In the transaction related to PO select the path goto->header texts and then details of the texts like ID,objectname,language,name.Pass all theses details to 'READ_TEXT '   FM. Then you will get text lines described for a perticular Po ,similarly for item also.
    Thanks,
    Suma.

  • Purpose of text element in scripts

    1. What is the purpose of text element in scripts. When do we use it ?
    2. Is text element window specific or only pertaning to main window ?

    Hi,
    text elements control the output of all data in sapscript forms windows.
    A text element starts with /E in the format column (switch to 'old' non-visual tect-editor to see) and has a name in the text line.
    The print program will fill the variables used as &symbols& in sapacript and then call the function WRITE_FORM for the element.
    In the main window, elements can be called repeatedly to output table-like data - usually the text elements are called something like ITEM_LINE then.
    Every window has a so-called default text element that has no name and is triggered without function call when the window is displayed. The default text element is the first one in the window. It is not preceded by /E. In other words: What you find on top of the window, before the first /E text element, is the default text element and is output without WRITE_FORM function call.
    It is quite well explained in documentation
    <a href="http://help.sap.com/saphelp_47x200/helpdata/en/d6/0db44e494511d182b70000e829fbfe/frameset.htm">BC SAPscript: Printing with Forms</a>
    Regards,
    Clemens

  • Translate the harcoded text written inside Script Editor in Adobe forms

    Hi Experts,
    In Adobe form, I have hardcoded a text inside the Script Editor.
    Now i need to maintain translation for it in another language.  Is it possible?
    I have checked option Goto -> Translation. But that text is not available there.
    Kindly give me some suggestions!

    I know what you are trying to do and that is NOT the way to handle it. haha This is EXACTLY why I never put texts to display within my script (Javascript). The better way to do it is this.....have a hidden text element on your form. Then show/hide it using your script. Since it is PART of the actual form, you can then translate it like you do anything else on the form. Works great!
    If you absolutely HAVE to do the text as a pop-up or something "off form", then there are ways to do it very similarly but takes a little more thought/work (ie. have your script read the text element's text and use that in your pop-up...again, since the text element is ON the form, you will get the correct translation.)
    Hope this helps!

  • How to give line height to text in AI Script

    how to give line height to text in AI Script

    I want to increase these three lines line height differently means i want script to increase the line height of outlined text

  • How to outline text in illustrator scripting

    I want to create storke in text in illustrator scripting and found one method too createoutline(),But How i used this method for text outline.

    var docRef = app.activeDocument;
    var colorForText = new CMYKColor();
        colorForText.black = 0;
        colorForText.cyan = 0;
        colorForText.magenta = 0;
        colorForText.yellow = 0;
    var colorForTextOutline = new CMYKColor();
    colorForTextOutline.black = 100;
    colorForTextOutline.cyan = 0;
    colorForTextOutline.magenta = 0;
    colorForTextOutline.yellow = 0;
    var outlineSize = 5;
    for (i = docRef.textFrames.length-1; i >=0; i--) {
        for (j = 0; j < docRef.textFrames[i].words.length; j++){
            docRef.textFrames[i].words[j].filled = true;
            docRef.textFrames[i].words[j].fillColor = colorForText;
    var outline = docRef.textFrames[i].duplicate(docRef, ElementPlacement.PLACEATEND);
        for (h = 0; h < outline.words.length; h++) {
            outline.words[h].filled = true;
            outline.words[h].fillColor = colorForTextOutline;
            outline.words[h].stroked = true;
            outline.words[h].strokeColor = colorForTextOutline;
            outline.words[h].strokeWeight = outlineSize;
    //docRef.textFrames[i].createOutline();
    //outline.createOutline();
    createOutline(); converts live text to outlines, if you are trying to just create a stroke you have to go about it a different way. This script will take the text and copy it, put it in back, and put a stroke behind on the behind text so it has an effect similar to an offset path. The way I have it leaves the text live, if you were wanting to convert the text to outlines as well I left that part written in the bottom of the script. There is also a StrokeJoin parameter as well.
    Hope this helps!

Maybe you are looking for

  • How to unmount a disk that thinks it's in use?

    Disk Utility will not Erase a backup hard drive disk b/c "Couldn't Unmount Disk." I've been trying to Erase a backup hard drive b/c it mistakenly thinks it's full, and in another discussion I was told to run Erase in Disk Utility.  No space on backup

  • Regarding workflow for OM infotype 1000,1001

    Hi all, i am having one scenerio. i have to trigger a mail when there in any create,delete,change in infotype 1000,1001. it should trigger a mail to the personal admin which is stored in 0001 infotype of that employee. how this can be achived? is the

  • Can't change metadata, keywords, colors

    In Bridge of CS3.  I have tried purging cache, resetting to default workspace, and automatically exporting cache to folder when possible. The problem cropped up recently.  I was able to add date, location etc to thousands of recent files, but now I a

  • ICal server migration stops with exception on a directory

    Hello, I've updated my Snow Leoparc server mac mini to Lion server. But the ical service don't manage to migrate my user from diskfiles to postgres. when I look in the /var/log/caldavd/error.log, I find this that seems revelent: 2011-10-29 23:48:39+0

  • 12c SOA multiple composite deployment using maven

    Hi, I am facing issue with 12c SOA composite deployment using maven. I execute the below command for deploying any composite. mvn pre-integration-test –f soa-pom.xml –Dcomposite.name=TestMVNProj –Dcomposite.version=1.1 Issues: As seen above by using