Zend_View-Helpers-HeadLink.xml 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect3 id="zend.view.helpers.initial.headlink">
  4. <title>HeadLink Helper</title>
  5. <para>
  6. The HTML <code>&lt;link&gt;</code> element is increasingly used for
  7. linking a variety of resources for your site: stylesheets, feeds,
  8. favicons, trackbacks, and more. The <code>HeadLink</code> helper
  9. provides a simple interface for creating and aggregating these elements
  10. for later retrieval and output in your layout script.
  11. </para>
  12. <para>
  13. The <code>HeadLink</code> helper has special methods for adding
  14. stylesheet links to its stack:
  15. </para>
  16. <itemizedlist>
  17. <listitem><para><code>appendStylesheet($href, $media,
  18. $conditionalStylesheet, $extras)</code></para></listitem>
  19. <listitem><para><code>offsetSetStylesheet($index, $href, $media,
  20. $conditionalStylesheet, $extras)</code></para></listitem>
  21. <listitem><para><code>prependStylesheet($href, $media,
  22. $conditionalStylesheet, $extras)</code></para></listitem>
  23. <listitem><para><code>setStylesheet($href, $media,
  24. $conditionalStylesheet, $extras)</code></para></listitem>
  25. </itemizedlist>
  26. <para>
  27. The <code>$media</code> value defaults to 'screen', but may be any valid
  28. media value. <code>$conditionalStylesheet</code> is a string or boolean false,
  29. and will be used at rendering time to determine if special comments should be
  30. included to prevent loading of the stylesheet on certain platforms.
  31. <code>$extras</code> is an array of any extra values that you want to be added
  32. to the tag.
  33. </para>
  34. <para>
  35. Additionally, the <code>HeadLink</code> helper has special methods for
  36. adding 'alternate' links to its stack:
  37. </para>
  38. <itemizedlist>
  39. <listitem><para><code>appendAlternate($href, $type,
  40. $title, $extras)</code></para></listitem>
  41. <listitem><para><code>offsetSetAlternate($index, $href, $type,
  42. $title, $extras)</code></para></listitem>
  43. <listitem><para><code>prependAlternate($href, $type,
  44. $title, $extras)</code></para></listitem>
  45. <listitem><para><code>setAlternate($href, $type,
  46. $title, $extras)</code></para></listitem>
  47. </itemizedlist>
  48. <para>
  49. The <code>headLink()</code> helper method allows specifying all
  50. attributes necessary for a <code>&lt;link&gt;</code> element, and allows
  51. you to also specify placement -- whether the new element replaces all
  52. others, prepends (top of stack), or appends (end of stack).
  53. </para>
  54. <para>
  55. The <code>HeadLink</code> helper is a concrete implementation of the
  56. <link linkend="zend.view.helpers.initial.placeholder">Placeholder
  57. helper</link>.
  58. </para>
  59. <example id="zend.view.helpers.initial.headlink.basicusage">
  60. <title>HeadLink Helper Basic Usage</title>
  61. <para>
  62. You may specify a <code>headLink</code> at any time. Typically, you
  63. will specify global links in your layout script, and application
  64. specific links in your application view scripts. In your layout
  65. script, in the &lt;head&gt; section, you will then echo the helper
  66. to output it.
  67. </para>
  68. <programlisting language="php"><![CDATA[
  69. <?php // setting links in a view script:
  70. $this->headLink()->appendStylesheet('/styles/basic.css')
  71. ->headLink(array('rel' => 'favicon',
  72. 'href' => '/img/favicon.ico'),
  73. 'PREPEND')
  74. ->prependStylesheet('/styles/moz.css',
  75. 'screen',
  76. true,
  77. array('id' => 'my_stylesheet'));
  78. ?>
  79. <?php // rendering the links: ?>
  80. <?php echo $this->headLink() ?>
  81. ]]></programlisting>
  82. </example>
  83. </sect3>
  84. <!--
  85. vim:se ts=4 sw=4 et:
  86. -->