Hi Tutorial City,
I would disagree since the controller’s main concern is handling the dispatching of requests and delegating the result of particular postbacks. In my opinion, the controller is supposed to adjust the view (or receive input from the view) based on certain business rules.
Adding an additional template to your view is still a part of configuring and loading the page. I suppose you could put the same code in the controller, but I would think it better to keep it specific to a view since the CSS your adding is only relavant to the presentation layer.
Thanks for the video.
I have found a different approach which may or may not be “good”.
I place a boolean var in my controller that I expose to the view.
($this->view->showMyCss = true;)
Then I place a check inside of my layout.phtml file.
$this->prependStylesheet(“/css/my.css”);
Yes, I do have to go to my controller if I wish to enable/disable it, but it seems a bit clearer to me from a logic standpoint.
Now, if I could only figure out how to pass data to a partial view I would be happy. Anyway, thanks for the vid, fastest creation of a menu I have seen.
Thanks for the vid. This is a bit off topic but what is the best way to add variables to the layout file. For example if i wanted to add a user name and account to to my layout.
I have a question. I use this method for my website. But there is a problem. My Css files will not be loaded. Thats true because the path to the Css file is:
/css/stylesheet.css
He can’t be loaded because Zend says that the Controller can not be found. I know that my map Css is staying in the map public, in the root of my website. So, how I can change it? That Zend can find the css file. Ideally I would that the .htacces file that is staying in my root, redirects the Css file. Is that possible? I hope that someone can help me.
Isn’t it a better idea to use the Controller to handle this stuff?
Hi Tutorial City,
I would disagree since the controller’s main concern is handling the dispatching of requests and delegating the result of particular postbacks. In my opinion, the controller is supposed to adjust the view (or receive input from the view) based on certain business rules.
Adding an additional template to your view is still a part of configuring and loading the page. I suppose you could put the same code in the controller, but I would think it better to keep it specific to a view since the CSS your adding is only relavant to the presentation layer.
Nice, but I prefer compressing css and putting all in one file, so they can stay cached and minimize the number of http requests for loading the page.
Thanks for this. this is very useful!
by the way, how is africa?
@Ali,
Namibia is awesome! I’m in Otjiwarongo right now
good video. i think u shld have prependStylesheet() in layout.phtml and appendStylesheet() in the view pages eg. home.phtml?
Thanks for the video.
I have found a different approach which may or may not be “good”.
I place a boolean var in my controller that I expose to the view.
($this->view->showMyCss = true;)
Then I place a check inside of my layout.phtml file.
$this->prependStylesheet(“/css/my.css”);
Yes, I do have to go to my controller if I wish to enable/disable it, but it seems a bit clearer to me from a logic standpoint.
Now, if I could only figure out how to pass data to a partial view I would be happy. Anyway, thanks for the vid, fastest creation of a menu I have seen.
@joel
Passing vars to a partial is done through the partial() view helper’s second argument:
$this->partial(“_mypartial.phtml”, array(“foo” => $foo, “bar” => $bar));
regards,
Sven
Thanks for the vid. This is a bit off topic but what is the best way to add variables to the layout file. For example if i wanted to add a user name and account to to my layout.
I have a question. I use this method for my website. But there is a problem. My Css files will not be loaded. Thats true because the path to the Css file is:
/css/stylesheet.css
He can’t be loaded because Zend says that the Controller can not be found. I know that my map Css is staying in the map public, in the root of my website. So, how I can change it? That Zend can find the css file. Ideally I would that the .htacces file that is staying in my root, redirects the Css file. Is that possible? I hope that someone can help me.