Zend_View-Helpers-HeadLink.xml 4.4 KB

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