Announcement

Collapse
No announcement yet.

Generate Random Number (template variable) for use in Ads code

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Generate Random Number (template variable) for use in Ads code

    I'm using a banner ad management script which, to prevent caching, requires a random number to be in the invocation code each time, e.g: -

    HTML Code:
    <img src='https://mydomain.com/www/delivery/avw.php?zoneid=1&amp;cb=INSERT_RANDOM_NUMBER_HERE&amp;n=aef5e321' border='0' alt='' />
    What I've tried so far: -

    Create a plugin hooked to "global_start" with the code: -

    PHP Code:
    $my_random_number rand(0,999999); 

    Then in the code for the ad HTML: -

    HTML Code:
    <img src='https://mydomain.com/www/delivery/avw.php?zoneid=1&amp;cb={vb:raw my_random_number}&amp;n=aef5e321' border='0' alt='' />
    However the variable is always blank.

    I thought this would be simple... any help greatly appreciated!

    ETA:
    vBulletin: 4.2.0
    PHP: 5.4.45
    MySQL: 5.7.28-log
    Default Style
    All browsers
    Last edited by John Alan; Thu 31st Oct '19, 8:23am.

  • #2
    It would probably be easier to create a random number in Javascript and then use Javascript to build the image tag for your ad.

    https://www.w3schools.com/jsref/jsref_random.asp

    To use a plugin, you need to register your variable so it is available to the template system. https://www.vbulletin.org/forum/showthread.php?t=299893
    Translations provided by Google.

    Wayne Luke
    The Rabid Badger - a vBulletin Cloud demonstration site.
    vBulletin 5 API - Full / Mobile
    Vote for your favorite feature requests and the bugs you want to see fixed.

    Comment


    • #3
      Originally posted by Wayne Luke View Post
      It would probably be easier to create a random number in Javascript and then use Javascript to build the image tag for your ad.

      https://www.w3schools.com/jsref/jsref_random.asp
      Thanks, but that's not an option. The invocation code is 2 part, the first part is javascript with it's own random number implementation, but the bit where I need to put my own is for the <noscript> alternative, so I need to do it another way.

      Originally posted by Wayne Luke View Post
      To use a plugin, you need to register your variable so it is available to the template system. https://www.vbulletin.org/forum/showthread.php?t=299893
      Thanks, I'll take a look.

      Comment

      Related Topics

      Collapse

      Working...
      X