[Solar-talk] Moving layout vars to outside

Rodrigo Moraes rodrigo.moraes at gmail.com
Sat Jan 27 05:43:00 PST 2007


Hi,
This is just something that helped me to manipulate layouts: I move
all $layout_* vars from Solar_App to a basic object which can be
extended to a more complex object that manipulate the page blocks.

The base class is Tipos_Response (I'm not sure if it is a good name),
which carries those $layout_* from Solar_App and $_layout /
$_layout_var from the Solar_Controller_Page. Then, for example, I
extend it in Tipos_Response_YuiGrids to manage a specific kind of
layout.

It adds pure flexibility because everything can also be configured
from outside (like: the controller asks a layout configuration to be
loaded), and then assigned to the view on _PreRender()...

    protected function _preRender($view)
    {
        // Add the response object to the view.
        $view->assign($this->_response);

        // For XmlHttpRequests, don't use a layout.
        if($this->_request->isXhr()) {
            $this->is_xhr = true;
        } else {
            $this->_layout_var = $this->_response->layout_var;
            $this->_layout = $this->_response->layout_template;
        }
    }

The flexibility is really the best part, but the move was easy and
straightforward, and the app code is much cleaner too. :-)

rodrigo


More information about the solar-talk mailing list