2011年2月11日星期五

[fw-mvc] Re: CSS/JS Includes

Thanks for the links. I'll definitely add the minify stuff.

About this page: http://devzone.zend.com/article/11760
I like how simple and elegant the solution is to include js/css by
controller and action. However, what if I have the same js that needs to be
included in two different actions or two different controllers?

In the comments of the above page, I found:
http://www.devpatch.com/2010/02/view-plugin/
I like what this person is saying, "In my approach loading up different
CSS/JS files per controller is the exception not the rule." Basically, have
your global stuff, but treat it controller-specific and action-specific
CSS/JS on a per-case basis (as needed). This is the solution my project is
using, but if I'm managing several controllers and several actions, it will
start to get messy and difficult to manage how all the different files are
included.

The idea I had in mind:
CSS/JS will be managed through configuration (XML). CSS/JS will be targeted
through routes and it will follow the same layout as the route
configuration. Create a concept of bundles which are groups of CSS/JS that
can be assigned to a route. Create concept of a global which will be
included on every page. Create concept of templates from which routes will
be allowed to inherit. A plugin will be responsible for including (and
minifying) js/css based on the configuration.

Sample XML:
<global>
<js>
<jquery>/js/jquery.js</jquery>
</js>
<css>
<main>/css/main.css</main>
</css
</global>

<about-route>
<css>
<about>/css/about.css</about>
</css>
<js>
<about>/js/about.js</about>
</js
</about-route>

-----
- Joe
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/CSS-JS-Includes-tp3300692p3302244.html
Sent from the Zend MVC mailing list archive at Nabble.com.

没有评论: