[tags]view, view.yml, symfony, reviewsby.us, title, seo[/tags]
A lot of the content on reviewsBy.us and other sites we make using symfony have dynamic content. We try to have our page titles reflect the content by prepending the name of the specific restaurant, document or menu item before the site name.
To do this we use a method called prependTitle. I define this in a file called myActions.class.php which almost all of my actions subclass in my projects. This way I can enhance all the actions simply by adjusting the common ancestor, myActions:
The page title isn't stored anywhere, so we have to put it in app.yml:
app:
title: reviewsby.us
Voila!



Great post. I also added the title from app.yml as a default title in view.yml like so:
default: metas: title: ”
Sorry! all the code got stripped. Should be:
default:
metas:
Great idea, I tweaked it a little and wrapped it in a private function, it should be much easier to do a $this->setTitle(‘About Us’);
Thanks for sharing.
/** * Pre Executes all actions */ public function preExecute() { $d = sfConfig::get(‘app_title_delimiter’); $t = sfConfig::get(‘app_title’); $this->title = array(‘d’ => $d, ‘t’ => $t); $this->response = $this->getResponse(); }
/** * Sets the Page Title * @param string $title The page title */ private function setTitle($title = ”) { $this->response->setTitle($title . $this->title['d'] . $this->title['t'], false); }
Hey Dave,
Great idea, I tweaked it a little and wrapped it in a private function, it should be much easier to do a $this->setTitle(‘About Us’);
Thanks for sharing, Joan.
/** * Pre Executes all actions */ public function preExecute() { $d = sfConfig::get('app_title_delimiter'); $t = sfConfig::get('app_title'); $this->title = array('d' => $d, 't' => $t); $this->response = $this->getResponse(); } /** * Sets the Page Title * @param string $title The page title */ private function setTitle($title = '') { $this->response->setTitle($title . $this->title['d'] . $this->title['t'], false); }