Zend_View-Helpers-HeadTitle.xml 2.4 KB

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