1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.1 Random node icon

Discussion in 'Styling and Customization Questions' started by Ingenious, Feb 26, 2014.

  1. Ingenious

    Ingenious Well-Known Member

    I've had a play and like having a custom node icon using the CSS below. My question is, what's the possibility of having a node icon change automatically, either randomly per page impression, or a different one each day? Can this be achieved via extra.css with a tweak to this code?

    Code:
    .node.node_84 .forumNodeInfo .nodeIcon, .node.node_84 .categoryForumNodeInfo .nodeIcon {
        background-image: url("styles/default/xenforo/widgets/customnode84.jpg") !important;
    background-repeat: no-repeat !important;
    background-position: 0px 0 !important;
    border-radius:5px;
    border-color: #000000;
    border-style: solid;
    border-width: 1px;
    }
     
  2. Ingenious

    Ingenious Well-Known Member

    Is there any reason why this doesn't work in extra.css?

    Code:
    <xen:set var="$rand">{xen:calc '({$serverTime} % 3) + 1'}</xen:set>
    
    .node.node_84 .forumNodeInfo .nodeIcon, .node.node_84 .categoryForumNodeInfo .nodeIcon {
        background-image: url("styles/default/xenforo/widgets/customnode{$rand}.jpg") !important;
    background-repeat: no-repeat !important;
    background-position: 0px 0 !important;
    border-radius:5px;
    border-color: #000000;
    border-style: solid;
    border-width: 1px;
    }
    
    $rand is always 1.

    Do these not work in extra.css? Exactly the same code used in any ad_ template does output a random number between 1 and 3 when $rand is output.

    Edit - after some testing it seems {%serverTime} is blank when used in extra.css, so $rand is always nothing + 1 = 1. Any way around this?
     
    Last edited: Feb 26, 2014
  3. Brogan

    Brogan XenForo Moderator Staff Member

    CSS templates don't support that xen syntax function.
     
  4. Ingenious

    Ingenious Well-Known Member

    Thanks Brogan :)
     

Share This Page