Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Random background image? [RESOLVED]
byakko
New
Hello! I'm trying to use this smarty tag to make a randomized background image on default.master.tpl but for some reason using the {capture} tag gives me a Something has gone wrong page.
{capture assign='num'}{1|rand:3}{/capture} <div id="header" style="background-image: url(header_bg{$num}.jpg)">
There are jQuery and php codes for this too but it seemed too extra to try to incorporate when smarty already had this.
Any thoughts why the {capture} tag isn't working? Thanks
0
Comments
Actually it's not the {capture} tag but rather the {1|rand:3} tag. the "rand" function is the culprit here, and I'm not exactly sure why.
-
SOLVED
https://vanillaforums.org/discussion/17445/solved-using-smarty-rand-in-master-view-tpl-doesnt-work
Thanks for posting your solution.