1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect3 id="zend.view.helpers.initial.headtitle">
4 <title>HeadTitle Helper</title>
7 The <acronym>HTML</acronym> <emphasis><title></emphasis> element is used to provide a
8 title for an <acronym>HTML</acronym> document. The <classname>HeadTitle</classname> helper
9 allows you to programmatically create and store the title for later retrieval and output.
13 The <classname>HeadTitle</classname> helper is a concrete implementation of the
14 <link linkend="zend.view.helpers.initial.placeholder">Placeholder
15 helper</link>. It overrides the <methodname>toString()</methodname> method to
16 enforce generating a <emphasis><title></emphasis> element, and adds a
17 <methodname>headTitle()</methodname> method for quick and easy setting and
18 aggregation of title elements. The signature for that method is
19 <methodname>headTitle($title, $setType = 'APPEND')</methodname>; by default, the
20 value is appended to the stack (aggregating title segments), but you may
21 also specify either 'PREPEND' (place at top of stack) or 'SET'
25 <example id="zend.view.helpers.initial.headtitle.basicusage">
26 <title>HeadTitle Helper Basic Usage</title>
29 You may specify a title tag at any time. A typical usage would have
30 you setting title segments for each level of depth in your
31 application: site, controller, action, and potentially resource.
34 <programlisting language="php"><![CDATA[
35 // setting the controller and action name as title segments:
36 $request = Zend_Controller_Front::getInstance()->getRequest();
37 $this->headTitle($request->getActionName())
38 ->headTitle($request->getControllerName());
40 // setting the site in the title; possibly in the layout script:
41 $this->headTitle('Zend Framework');
43 // setting a separator string for segments:
44 $this->headTitle()->setSeparator(' / ');
48 When you're finally ready to render the title in your layout
49 script, simply echo the helper:
52 <programlisting language="php"><![CDATA[
53 <!-- renders <action> / <controller> / Zend Framework -->
54 <?php echo $this->headTitle() ?>