Zend_View-Helpers-HeadTitle.xml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 = null)</methodname>; by default, the
  18. value is appended to the stack (aggregating title segments) if left at null, but you may
  19. also specify either 'PREPEND' (place at top of stack) or 'SET'
  20. (overwrite stack).
  21. </para>
  22. <para>
  23. Since setting the aggregating (attach) order on each call to <methodname>
  24. headTitle</methodname> can be cumbersome, you can set a default attach order
  25. by calling <methodname>setDefaultAttachOrder()</methodname> which is applied
  26. to all <methodname>headTitle()</methodname> calls unless you explicitly
  27. pass a different attach order as the second parameter.
  28. </para>
  29. <example id="zend.view.helpers.initial.headtitle.basicusage">
  30. <title>HeadTitle Helper Basic Usage</title>
  31. <para>
  32. You may specify a title tag at any time. A typical usage would have
  33. you setting title segments for each level of depth in your
  34. application: site, controller, action, and potentially resource.
  35. </para>
  36. <programlisting language="php"><![CDATA[
  37. // setting the controller and action name as title segments:
  38. $request = Zend_Controller_Front::getInstance()->getRequest();
  39. $this->headTitle($request->getActionName())
  40. ->headTitle($request->getControllerName());
  41. // setting the site in the title; possibly in the layout script:
  42. $this->headTitle('Zend Framework');
  43. // setting a separator string for segments:
  44. $this->headTitle()->setSeparator(' / ');
  45. ]]></programlisting>
  46. <para>
  47. When you're finally ready to render the title in your layout
  48. script, simply echo the helper:
  49. </para>
  50. <programlisting language="php"><![CDATA[
  51. <!-- renders <action> / <controller> / Zend Framework -->
  52. <?php echo $this->headTitle() ?>
  53. ]]></programlisting>
  54. </example>
  55. </sect3>
  56. <!--
  57. vim:se ts=4 sw=4 et:
  58. -->