I want to share a simple, yet very useful, custom Zend Framework plugin that we use on almost all of our projects. The plugin (and associated code in the layout file) provides the Zend Framework route context as CSS classes on the
default, the controller name was
news, and the action was
get then the opening of the
body element would like this:
<body class="default news get">
There are some limitations. For example, you need to be careful not to overlap module, controller, or action names. If this is a problem for you then you could preface the class names (e.g.
The RouteContext plugin hooks into the
preDispatch event and creates an array of route context strings. This example simply uses the module, controller, and action names as the route context. Often I’ll add other contextual strings to this array as needed. This array is then assigned to the view. The layout view script then simply implodes this array into the value of the
class attribute using a space character as the glue.