XF 1.1 Random node icon

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;
}
 
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:
Back
Top Bottom