Announcement

Collapse
No announcement yet.

Setting a variable for use within a template

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

  • Wayne Luke
    replied
    Originally posted by Shon View Post
    Honestly, I'm trying to use a variable for a random number in the header template.

    I'm trying to recreate my modification I used from vB4.x on 5.6.4 to show an image similar to:

    HTML Code:
    <img src="/folder/{vb:set randnum, $randomnum}.jpg" />
    Can do this with Javascript...

    https://forum.vbulletin.com/forum/vb...93#post4369293

    Leave a comment:


  • Shon
    replied
    Originally posted by yilmaz View Post
    A simple api plug.
    It doesn't work without api
    I uploaded it to review and try.
    This could be improved.
    Thank you for your response... I've posted a response to your thread for this on vbulletin.org, as it seems to be be more appropriate there, to see if you can help with going about using\customizing your example with a template.

    Leave a comment:


  • yilmaz
    replied
    A simple api plug.
    It doesn't work without api
    I uploaded it to review and try.
    This could be improved.

    Demo Video


    Plug url https://www.vbulletin.org/forum/showthread.php?t=328332
    Last edited by yilmaz; Thu 5 Nov '20, 4:12am.

    Leave a comment:


  • Shon
    replied
    Originally posted by yilmaz View Post
    Which template do you want to make?
    Custom template?
    Standard template?
    Honestly, I'm trying to use a variable for a random number in the header template.

    I'm trying to recreate my modification I used from vB4.x on 5.6.4 to show an image similar to:

    HTML Code:
    <img src="/folder/{vb:set randnum, $randomnum}.jpg" />
    Last edited by Shon; Wed 4 Nov '20, 5:52pm.

    Leave a comment:


  • yilmaz
    replied
    Which template do you want to make?
    Custom template?
    Standard template?

    Leave a comment:


  • Shon
    started a topic Setting a variable for use within a template

    Setting a variable for use within a template

    I'm learning a little bit about {vb:set ...} and {vb:raw ... } but I am not quite sure how to accomplish using that to set a custom variable to simple a random number.

    I'm trying to do exactly this:

    PHP Code:
    $randomnum rand(1,112); 
    Code:
    {vb:set randnum, $randomnum}
    Then use the random number inside the same template:
    Code:
    {vb:raw randnum}
    I've saw there is a php function for {vb:...}, but it doesn't look like I would be able to accomplish that using that. Is there an easy way to go about doing this?
    Last edited by Shon; Wed 4 Nov '20, 11:03am.

Related Topics

Collapse

Working...
X