Jake B.
Well-known member
Currently (at least from what I can tell), you can't pass additional variables to css templates using template_create like you can for normal templates, and XenForo_CssOutput has the following contents:
Just curious if it'd be possible to get some sort of code event, or even have a 'protected function _cssParams()' that returns an array of the parameters so Add-on developers can add additional parameters to it (It of course, would be on the developer to take into account any CSS caching and not use things that change often)
Regards,
Jake
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;
}
Just curious if it'd be possible to get some sort of code event, or even have a 'protected function _cssParams()' that returns an array of the parameters so Add-on developers can add additional parameters to it (It of course, would be on the developer to take into account any CSS caching and not use things that change often)
Regards,
Jake
Upvote
0