I'm creating joomla template using blank joomla starter template. The blank joomla template has a file called template.css.php that combines and compresses multiple template css files into one single file output for lowering http request. This template.css.php can be accessed directly from browser (direct access) and will return compressed css code output.
For some reasons I need to call my template parameters from the inside of template.css.php but when I try to get template parameters, the file template.css.php is no longer available for direct access. It will return a blank page.
Any idea how to get this work?
Here is the modified version of my template.css.php file :
<?php
/* modified code START */
require_once ( '../../../includes/defines.php' );
require_once ( '../../../includes/framework.php' );
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$params = $app->getParams();
$pageclass = $params->get('pageclass_sfx');
/* modified code END */
// initialize ob_gzhandler to send and compress data
ob_start ("ob_gzhandler");
// initialize compress function for whitespace removal
ob_start("compress");
// required header info and character set
header("Content-type:text/css; charset=UTF-8");
// cache control to process
header("Cache-Control:must-revalidate");
// duration of cached content (1 hour)
$offset = 60 * 60 ;
// expiration header format
$ExpStr = "Expires: " . gmdate("D, d M Y H:i:s",time() + $offset) . " GMT";
// send cache expiration header to broswer
header($ExpStr);
// begin function compress
function compress($buffer) {
// remove comments
$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
// remove tabs, spaces, new lines, etc.
$buffer = str_replace(array("\r\n","\r","\n","\t",' ',' ',' '),'',$buffer);
// remove unnecessary spaces
$buffer = str_replace('{ ', '{', $buffer);
$buffer = str_replace(' }', '}', $buffer);
$buffer = str_replace('; ', ';', $buffer);
$buffer = str_replace(', ', ',', $buffer);
$buffer = str_replace(' {', '{', $buffer);
$buffer = str_replace('} ', '}', $buffer);
$buffer = str_replace(': ', ':', $buffer);
$buffer = str_replace(' ,', ',', $buffer);
$buffer = str_replace(' ;', ';', $buffer);
$buffer = str_replace(';}', '}', $buffer);
return $buffer;
}
// uikit.css
require('uikit.min.css');
require('uikit/slider.css');
require('uikit/slidenav.css');
// template css
require('template.css');
// load system stylesheets for system messages and default buttons
require('../../../media/system/css/system.css');
require('../../system/css/system.css');
require('../../system/css/general.css');
?>