Kostache. Variables "dinámicas" en la vista

What is the preferred way of setting some View variables which values depend on parameters passed to the View from the Controller? (Examples of the variables may be page title and page description)

OPT1) Set it directly from the Controller (puts some view logic there).

OPT2) Create View method for every "dynamic" variable.

OPT3) Extend base View class with "after" method that sets everything just before the rendering.

preguntado el 09 de marzo de 12 a las 16:03

1 Respuestas

In the case of page title and description, the view should know this stuff. This can take the advantage of inheritance, too.

class View_Home extends View_Layout {
    public $title = 'Home';
    public $current_menu_item = 'home';
}

If needed, pass the controller params to the view.

respondido 12 mar '12, 11:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.