Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I am trying to do the same thing right now. I am looking at NC State University's OT Framework, based on Zend Framework. This is implemented as a view helper. It has a nice class to minify all headscripts and headlinks via the Minify on Google Code:</p> <p><a href="http://ot.ncsu.edu/2010/03/03/getting-started-with-ot-framework/" rel="nofollow">http://ot.ncsu.edu/2010/03/03/getting-started-with-ot-framework/</a></p> <p>Headscripts:</p> <pre><code>&lt;?php /** * Minifies the javascript files added via the minifyHeadScript helper using * minify (http://code.google.com/p/minify/) * */ class Ot_View_Helper_MinifyHeadScript extends Zend_View_Helper_HeadScript { protected $_regKey = 'Ot_View_Helper_MinifyHeadScript'; public function minifyHeadScript($mode = Zend_View_Helper_HeadScript::FILE, $spec = null, $placement = 'APPEND', array $attrs = array(), $type = 'text/javascript') { return parent::headScript($mode, $spec, $placement, $attrs, $type); } public function toString() { $items = array(); $scripts = array(); $baseUrl = $this-&gt;getBaseUrl(); // we can only support files foreach ($this as $item) { if (isset($item-&gt;attributes['src']) &amp;&amp; !empty($item-&gt;attributes['src'])) { $scripts[] = str_replace($baseUrl, '', $item-&gt;attributes['src']); } } //remove the slash at the beginning if there is one if (substr($baseUrl, 0, 1) == '/') { $baseUrl = substr($baseUrl, 1); } $item = new stdClass(); $item-&gt;type = 'text/javascript'; $item-&gt;attributes['src'] = $this-&gt;getMinUrl() . '?b=' . $baseUrl . '&amp;f=' . implode(',', $scripts); $scriptTag = $this-&gt;itemToString($item, '', '', ''); return $scriptTag; } public function getMinUrl() { return $this-&gt;getBaseUrl() . '/min/'; } public function getBaseUrl(){ return Zend_Controller_Front::getInstance()-&gt;getBaseUrl(); } } </code></pre> <p>And here is the code for headlinks:</p> <pre><code>&lt;?php /** * Minifies the stylesheets added via the minifyHeadLink helper using * minify (http://code.google.com/p/minify/) * */ class Ot_View_Helper_MinifyHeadLink extends Zend_View_Helper_HeadLink { protected $_regKey = 'Ot_View_Helper_MinifyHeadLink'; public function minifyHeadLink(array $attributes = null, $placement = Zend_View_Helper_Placeholder_Container_Abstract::APPEND) { return parent::headlink($attributes, $placement); } public function toString() { $items = array(); $stylesheets = array(); $baseUrl = $this-&gt;getBaseUrl(); foreach ($this as $item) { if ($item-&gt;type == 'text/css' &amp;&amp; $item-&gt;conditionalStylesheet === false) { $stylesheets[$item-&gt;media][] = str_replace($baseUrl, '', $item-&gt;href); } else { $items[] = $this-&gt;itemToString($item); } } //remove the slash at the beginning if there is one if (substr($baseUrl, 0, 1) == '/') { $baseUrl = substr($baseUrl, 1); } foreach ($stylesheets as $media=&gt;$styles) { $item = new stdClass(); $item-&gt;rel = 'stylesheet'; $item-&gt;type = 'text/css'; $item-&gt;href = $this-&gt;getMinUrl() . '?b=' . $baseUrl . '&amp;f=' . implode(',', $styles); $item-&gt;media = $media; $item-&gt;conditionalStylesheet = false; $items[] = $this-&gt;itemToString($item); } $link = implode($this-&gt;_escape($this-&gt;getSeparator()), $items); return $link; } public function getMinUrl() { return $this-&gt;getBaseUrl() . '/min/'; } public function getBaseUrl(){ return Zend_Controller_Front::getInstance()-&gt;getBaseUrl(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload