For anyone out there using compressed javascript or css files, Zoop has a great convention for allowing you to switch files during different development phases. The app_status variable is set in the config.php file and can be assign to the gui and used in templates. If you keep the javascript files in a javascript.tpl and the css files in a css.tpl you can call different files depending on the application state. For anyone looking for more information on compressing javascript and css files check out http://developer.yahoo.com/yui/compressor/
For this example we will assume I have one javascript file called common.js and one css file called main.css both located in the applications public/resources folders. Call the uncompressed files common.src.js and main.src.js and the compressed files common.js and main.css.
In my default zone (zone_default.php) I would add the following code to add app_status as a variable in the templates:
public function initZone($inPath)
{
self::guiAssign('app_status',app_status);
}My javascript template file (javascript.tpl) would look like:
{ if app_status == 'dev' }
<script type="text/javascript" src="public/resources/js/common.src.js"></script>
{ else }
<script type="text/javascript" src="public/resources/js/common.src.js"></script>
{ /if }My css template file (css.tpl) would look like:
{ if app_status == 'dev' }
<link href="public/resources/css/main.src.css" rel="stylesheet" type="text/css"/>
{ else }
<link href="public/resources/css/main.css" rel="stylesheet" type="text/css"/>
{ /if }You can then include both of the files in the head section of your HTML.
{ include file="css.tpl" }
{ include file="javascript.tpl" }
Recent comments
9 hours 31 min ago
3 days 19 hours ago
4 days 20 hours ago
4 days 23 hours ago
5 days 17 hours ago
2 weeks 3 days ago
2 weeks 3 days ago
2 weeks 3 days ago
3 weeks 1 day ago
3 weeks 1 day ago