| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!-- Reviewed: no -->
- <sect3 id="zend.view.helpers.initial.headtitle">
- <title>HeadTitle Helper</title>
- <para>
- The <acronym>HTML</acronym> <emphasis><title></emphasis> element is used to provide a
- title for an <acronym>HTML</acronym> document. The <classname>HeadTitle</classname> helper
- allows you to programmatically create and store the title for later retrieval and output.
- </para>
- <para>
- The <classname>HeadTitle</classname> helper is a concrete implementation of the
- <link linkend="zend.view.helpers.initial.placeholder">Placeholder
- helper</link>. It overrides the <methodname>toString()</methodname> method to
- enforce generating a <emphasis><title></emphasis> element, and adds a
- <methodname>headTitle()</methodname> method for quick and easy setting and
- aggregation of title elements. The signature for that method is
- <methodname>headTitle($title, $setType = null)</methodname>; by default, the
- value is appended to the stack (aggregating title segments) if left at null, but you may
- also specify either 'PREPEND' (place at top of stack) or 'SET'
- (overwrite stack).
- </para>
- <para>
- Since setting the aggregating (attach) order on each call to <methodname>
- headTitle</methodname> can be cumbersome, you can set a default attach order
- by calling <methodname>setDefaultAttachOrder()</methodname> which is applied
- to all <methodname>headTitle()</methodname> calls unless you explicitly
- pass a different attach order as the second parameter.
- </para>
- <example id="zend.view.helpers.initial.headtitle.basicusage">
- <title>HeadTitle Helper Basic Usage</title>
- <para>
- You may specify a title tag at any time. A typical usage would have
- you setting title segments for each level of depth in your
- application: site, controller, action, and potentially resource.
- </para>
- <programlisting language="php"><![CDATA[
- // setting the controller and action name as title segments:
- $request = Zend_Controller_Front::getInstance()->getRequest();
- $this->headTitle($request->getActionName())
- ->headTitle($request->getControllerName());
- // setting the site in the title; possibly in the layout script:
- $this->headTitle('Zend Framework');
- // setting a separator string for segments:
- $this->headTitle()->setSeparator(' / ');
- ]]></programlisting>
- <para>
- When you're finally ready to render the title in your layout
- script, simply echo the helper:
- </para>
- <programlisting language="php"><![CDATA[
- <!-- renders <action> / <controller> / Zend Framework -->
- <?php echo $this->headTitle() ?>
- ]]></programlisting>
- </example>
- </sect3>
- <!--
- vim:se ts=4 sw=4 et:
- -->
|