View_Helper Minify StyleSheets
1 2 3 4 56 7 8 9 1011 12 13 14 1516 17 18 19 2021 22 23 24 2526 27 28 29 30 | <?php class GSD_View_Helper_MinStyleSheets extends Zend_View_Helper_HeadLink { public function minStyleSheets() { $items = array(); $stylesheets = array(); foreach ($this as $item) { if ($item->type == 'text/css' && $item->conditionalStylesheet === false) { $stylesheets[$item->media][] = $item->href; } else { $items[] = $this->itemToString($item); } } foreach ($stylesheets as $media=>$styles) { $item = new stdClass(); $item->rel = 'stylesheet'; $item->type = 'text/css'; $item->href = $this->getMinUrl() . '?f=' . implode(',', $styles); $item->media = $media; $item->conditionalStylesheet = false; $items[] = $this->itemToString($item); } return $indent . implode($this->_escape($this->getSeparator()) . $indent, $items); } public function getMinUrl() { return $this->getBaseUrl() . '/public/min/'; } public function getBaseUrl() { return GSD_View_Helper_GetUrl::getBaseUrl(); } } |
Comments
You must login before commenting on a snippet. If you do not have an account, please register.
Snippet description
A view helper implementation that will minify the css external files.
It will work in conjunction with Zend_View HeadLink Helper to place your css files.
It will only give you another method of rendering the html to place your files in head section.
more details here
http://www.gsdesign.ro/blog/minify-css-in-zendframework/
Snippet details
- Created:
-
gabriel solomon
- Edited:
-
gabriel solomon
- Revision Id:
- 69
- Edit Message:
- Initial Release
- Tags:
- view helper minify css
- Comments:
- 1
- Views:
- 2585
- Points:
- 3 (3 votes)
11 months ago
I appreciated your post, I ran across the same problem and ended up writing two drop-in helpers to manage it for me. You can see them at http://blog.hines57.com/2011/03/13/zendframework-minify/ - thanks again.