XF 1.2 Custom Template Variable

Lukas W.

Formerly katsulynx
Is there a way to use a custom variable in the xenforo templates? I want to implement a background changer with a picture url stored into a cookie. Currently I am changing the background picture with jQuery every time the page is loaded but this is more than inefficient.

Best way would be to store the cookie value somewhere in the templates into a variable like the font-colors and then be able to open it in css whereever needed with something like '@background' or so. Is this possible?

Lukas W.

Formerly katsulynx
As nobody seemed to know if it is possible or not, I tried to do a workaround with the callback function. It may not be as pretty as defining the variable once and use it wherever needed, but it works... mostly. The callback is set up to return the variable of the cookie if existing, if not, the standard background url. Unfortunately, it does not seem to recognize my cookies...

Is callback able to handle cookies or not?
Callback looks like this:

class Mycallback_Background {
    public static function getBackground() {
        if (isset($_COOKIE['background']))
            $output = $_COOKIE['background'];
            $output = "styles/kitsunebi/xenforo/kitsunebi_IMG/background.png";
        echo $output;


Lukas W.

Formerly katsulynx
Still noone to help? :(

I figured out cookies are working but it takes time for the callback to update and refresh. So everytime I change the cookie I have to wait until the change is recognized by the callback. This takes time up to 15 minutes. Is there a way to make the callback update more often or maybe really to create a template variable?
Last edited: