dev-master
9999999-dev
The Requires
ZfAssetic is two ViewHelper that helps developper to integrate Assetic in Zend Framework views., (*1)
<?php // In your view... $this->cssAsset()->captureStart(); ?> <link rel="stylesheet" type="text/css" href="/media/css/styles.css" /> <link rel="stylesheet" type="text/css" href="/media/css/box.css" /> <?php $this->cssAsset()->captureStart(); echo $this->cssAsset(); // Will output something like this : // <link rel="stylesheet" type="text/css" href="/asset/0141522526d6be5302041ffa6093933b.css" /> ?>
To use these helpers, you have to create an Assetic AssetFactory that manages
filters. The factory can then be added directly to the helper using the method
setAssetFactory()
or by setting the key AssetFactory to the Zend_Registry :, (*2)
<?php $factory = new Assetic\Factory\AssetFactory('/path/where/files/to/be/filtered/are'); $helper = new ZfAssetic_ViewHelper_CssAsset(); $helper->setAssetFactory($factory); // Or... Zend_Registry::set('AssetFactory', $factory);
Also, you have to set the path where to put the generated asset and the path where your webserver is configured to serve files :, (*3)
<?php $helper = new ZfAssetic_ViewHelper_CssAsset(); $public_dir = "/var/www"; $asset_dir = "/var/www/assets"; $helper->setPublicDirectory($public_dir); $helper->setAssetDirectory($asset_dir);