| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!-- Reviewed: no -->
- <sect3 id="zend.view.helpers.initial.headtitle">
- <title>HeadTitle Helper</title>
- <para>
- The HTML <code><title></code> element is used to provide a title
- for an HTML document. The <code>HeadTitle</code> helper allows you to
- programmatically create and store the title for later retrieval and
- output.
- </para>
- <para>
- The <code>HeadTitle</code> helper is a concrete implementation of the
- <link linkend="zend.view.helpers.initial.placeholder">Placeholder
- helper</link>. It overrides the <code>toString()</code> method to
- enforce generating a <code><title></code> element, and adds a
- <code>headTitle()</code> method for quick and easy setting and
- aggregation of title elements. The signature for that method is
- <code>headTitle($title, $setType = 'APPEND')</code>; by default, the
- value is appended to the stack (aggregating title segments), but you may
- also specify either 'PREPEND' (place at top of stack) or 'SET'
- (overwrite stack).
- </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:
- -->
|