Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Default title, assets defined in layout or better in a event?[solved]

Hi, I created my base layout and defined there in the head my default assets.

<?php
/* @var $this \Phalcon\Mvc\View\Engine\Php */
$this->tag->setDoctype(\Phalcon\Tag::HTML5);
$this->tag->setTitle("Default Title");
$this->assets->addCss('css/bootstrap.min.css')
             ->addCss('css/style.css');
$this->assets->addJs('js/jquery.js')
            ->addJs('js/bootstrap.min.js');
?>
<?=$this->tag->getDoctype();?>
<html>....

Is this the usual way or should I define the default assets and my default title in a view event like beforeRenderView? Somehow I have the feeling that it is better to define the base title/assets in an event because view's shouldn't have any logic.



1.5k
Accepted
answer

Okay I think I got it. I moved the data to the ControllerBase class initialize function. I think this makes more sense. If someone has a better solution/way to do this please let me know.