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

template_create for css templates?

Jake B.

Well-known member
#1
I'm trying to use template_create to add a couple variables to a css file. However, it appears template_create doesn't run for css templates. Is there any sort of known workaround for this?

- Jake
 

Jake B.

Well-known member
#3
Guess I'll have to put the css into the page_container then. I was digging through XenForo to find where xenOptions was added and I found this in XenForo_CssOutput

Code:
public function renderCss()
    {
        $cacheId = 'xfCssCache_' . sha1(
            'style=' . $this->_styleId .
            'css=' . serialize($this->_cssRequested) .
            'd=' . $this->_inputModifiedDate .
            'dir=' . $this->_textDirection .
            'minify=' . XenForo_Application::get('options')->minifyCss)
            . (XenForo_Application::debugMode() ? 'debug' : '');

        if ($cacheObject = XenForo_Application::getCache())
        {
            if ($cacheCss = $cacheObject->load($cacheId, true))
            {
                return $cacheCss . "\n/* CSS returned from cache. */";
            }
        }

        $this->_prepareForOutput();

        if (XenForo_Application::isRegistered('bbCode'))
        {
            $bbCodeCache = XenForo_Application::get('bbCode');
        }
        else
        {
            $bbCodeCache = XenForo_Model::create('XenForo_Model_BbCode')->getBbCodeCache();
        }

        $params = array(
            'displayStyles' => $this->_displayStyles,
            'smilieSprites' => $this->_smilieSprites,
            'customBbCodes' => !empty($bbCodeCache['bbCodes']) ? $bbCodeCache['bbCodes'] : array(),
            'xenOptions' => XenForo_Application::get('options')->getOptions(),
            'dir' => $this->_textDirection,
            'pageIsRtl' => ($this->_textDirection == 'RTL')
        );

        var_dump($params);die;

        $templates = array();
        foreach ($this->_cssRequested AS $cssName)
        {
            $cssName = trim($cssName);
            if (!$cssName)
            {
                continue;
            }

            $templateName = $cssName . '.css';
            if (!isset($templates[$templateName]))
            {
                $templates[$templateName] = new XenForo_Template_Public($templateName, $params);
            }
        }

        $css = self::renderCssFromObjects($templates, XenForo_Application::debugMode());
        $css = self::prepareCssForOutput(
            $css,
            $this->_textDirection,
            (XenForo_Application::get('options')->minifyCss && $cacheObject)
        );

        if ($cacheObject)
        {
            $cacheObject->save($css, $cacheId, array(), 86400);
        }

        return $css;
    }
But can't really do anything with that without overwriting the entire method though unfortunately :\ Guess I'll just stick the CSS into page_container