<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

 <title>Dave Dash</title>
 <link href="http://davedash.com/tag/title/atom.xml" rel="self"/>
 <link href="http://davedash.com/tag/title"/>
 <updated>2012-04-07T22:42:44-07:00</updated>
 <id>http://davedash.com/</id>
 <author>
   <name>Dave Dash</name>
   <email>dd+atom1@davedash.com</email>
 </author>

 
 <entry>
   <title>Dynamically adjusting your page title in symfony</title>
   <link href="http://davedash.com/2007/07/18/dynamically-adjusting-your-page-title-in-symfony/"/>
   <updated>2007-07-18T00:00:00-07:00</updated>
   <id>http://davedash.com/2007/07/18/dynamically-adjusting-your-page-title-in-symfony</id>
   <content type="html">&lt;p&gt;[tags]view, view.yml, symfony, reviewsby.us, title, seo[/tags]&lt;/p&gt;

&lt;p&gt;A lot of the content on &lt;a href=&quot;http://reviewsby.us/&quot;&gt;reviewsBy.us&lt;/a&gt; and other sites we make using &lt;a href=&quot;http://symfony-project.com/&quot;&gt;symfony&lt;/a&gt; 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.&lt;/p&gt;

&lt;p&gt;To do this we use a method called &lt;code&gt;prependTitle&lt;/code&gt;.  I define this in a file called &lt;code&gt;myActions.class.php&lt;/code&gt; which almost all of my actions subclass in my projects.  This way I can enhance all the actions simply by adjusting the common ancestor, &lt;code&gt;myActions&lt;/code&gt;:&lt;/p&gt;

&lt;div&gt;&lt;textarea name=&quot;code&quot; class=&quot;php&quot;&gt;
      public function prependTitle($title)
      {
        $r = $this-&gt;getResponse();
        $d = sfConfig::get('app_title_delimiter', ' &amp;laquo; ');
        $t = sfConfig::get('app_title');
        $r-&gt;setTitle($title.$d.$t, false);
      }
&lt;/textarea&gt;&lt;/div&gt;


&lt;p&gt;The page title isn't stored anywhere, so we have to put it in &lt;code&gt;app.yml&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;app:
  title: reviewsby.us
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Voila!&lt;/p&gt;
</content>
 </entry>
 

</feed>

