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
1 hour 6 min ago
1 hour 40 min ago
1 hour 41 min ago
4 hours 4 min ago
11 hours 27 min ago
11 hours 29 min ago
11 hours 31 min ago
12 hours 23 min ago
12 hours 31 min ago
12 hours 43 min ago