Zend_View-Helpers-HeadTitle.xml 2.3 KB

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