Dynamically adjusting your page title in symfony

[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!