Created
September 13, 2012 11:50
-
-
Save mattattui/3713822 to your computer and use it in GitHub Desktop.
Symfony 1.4 versioned stylesheets/css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app: | |
# ... | |
resource_version: <?php echo date_create()->format('YmdHis'); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function include_stylesheets_versioned() | |
{ | |
$response = sfContext::getInstance()->getResponse(); | |
sfConfig::set('symfony.asset.stylesheets_included', true); | |
$html = ''; | |
foreach ($response->getStylesheets() as $file => $options) { | |
if ((strpos($file, '?') === false) && (stripos($file, 'http') !== 0) ) { | |
$file .= '?v='.sfConfig::get('app_resource_version'); | |
} | |
$html .= stylesheet_tag($file, $options); | |
} | |
echo $html; | |
} | |
function include_javascripts_versioned() | |
{ | |
$response = sfContext::getInstance()->getResponse(); | |
sfConfig::set('symfony.asset.javascripts_included', true); | |
$html = ''; | |
foreach ($response->getJavascripts() as $file => $options) { | |
if ((strpos($file, '?') === false) && (stripos($file, 'http') !== 0) ) { | |
$file .= '?v='.sfConfig::get('app_resource_version'); | |
} | |
$html .= javascript_include_tag($file, $options); | |
} | |
echo $html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Excellent Helper! I'll add some clarification about how to implement this for other devs.
In
settings.yml
you have to configurestandard_helpers
, notdefault_modules
, like ie:standard_helpers: [Partial, Cache, glxAsset]
You want to include Partial and Cache, which are the default ones
If you like to do this in a "by template" fashion, you can add this line at the beginning of your layout.php:
<?php use_helper('glxAsset') ?>
How this tips helps others..