Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Oct 2002
    Posts
    137
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Do you think my random code for adsense/gif-banners will work in a vbulletin template

    I want to randomly display my adsense script and a banner or two. Could I insert something like this into my header template:

    Code:
    <?php
    $number=mt_rand(1, 2);
    if ($number==1) 
    {
    include "http://www.volconvo.com/adsense.txt"; 
    }
    else
    {
    include "http://www.volconvo.com/banners.txt"; 
    }
    ?>
    With those .txt files full of their respective codes...

    Or would you do something else?

  • #2
    New Coder
    Join Date
    Sep 2005
    Location
    Berlin, Germany
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    the content of templates is usually not included and thus php-code won't be parsed. (get_contents is used instead).
    So you'll need to put this somewhere else.

  • #3
    Regular Coder
    Join Date
    Oct 2002
    Posts
    137
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hmm...

    What type of language would I have to use to actually be able to place this in vbulletin? javascript?

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    The problem with this an the vbulletin scripting (depending on your version), is that vB 3.x will accept limited functions for their templates, due to their 'simplistic' methods. vB templates are called using eval() functions, which will evaluate any php contained within them. 3.x versions will be tricky at best though, I'd personally recommend another routine for this.
    Take your global.php file, add what you have, but capture this information into a new variable. You can now use this variable within the actual vBulletin templates. Instead of using include structures, use a file() method instead (file_get_contents, readfile, etc), anything to put it into a string. Name your variable accordingly though, you don't want to overwrite a vbulletin template call.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •