1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Random quotes in cgiproxy

Discussion in 'Programming' started by eXe, Sep 7, 2007.

  1. #1
    How do I display random quotes in the cgiproxy script?
     
    eXe, Sep 7, 2007 IP
  2. sea otter

    sea otter Peon

    Messages:
    250
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Basically, you need to create an html fragment containing the random quote, and then assign that code fragment string to the $INSERT_HTML variable.

    You'll also need to change the $INSERTION_FRAME_HEIGHT variable to accommodate the height of your displayed quote. Otherwise, it will get cut off.

    I can't post any specific code, because I don't know how your random quotes are stored and how you plan to retrieve them for insertion into the html fragment.

    Hope that helps.
     
    sea otter, Sep 7, 2007 IP
  3. sea otter

    sea otter Peon

    Messages:
    250
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #3
    OK, here's an example of how to do this with some hardcoded quotes right in the script.

    First, find this string in the script file:

    
    #$INSERT_HTML= "<h1>This is an inserted header</h1><hr>" ;
    
    Code (markup):
    It should be somewhere near line 555.

    Now we'll add the code to randomly select and display the quote right below the line you just found:

    
    my @quotes = (
    	'Nothing ventured, nothing gained.',
    	'I love the <a href="http://forums.digitalpoint.com">DigitalPoint</a> forums!',
    	'When a programmer gives you an estimate, triple it.'
    );
    
    my $quote = $quotes[int(rand(@quotes))];
    
    $INSERT_HTML = '<div class="random_quote">' . $quote . '</div><hr />';
    
    Code (markup):
    That's it. A very simple example. Tested and works.

    Things are a little different if you want to read the data from a file or change the proxy toolbar code and actually insert the quote into that, or do some fancy CSS formatting on the quote, but this is the basic mechanism.

    Post back if you have any more questions.
     
    sea otter, Sep 21, 2007 IP
    eXe likes this.