1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect3 id="zend.view.helpers.initial.headlink">
4 <title>HeadLink Helper</title>
7 The HTML <emphasis><link></emphasis> element is increasingly used for
8 linking a variety of resources for your site: stylesheets, feeds,
9 favicons, trackbacks, and more. The <classname>HeadLink</classname> helper
10 provides a simple interface for creating and aggregating these elements
11 for later retrieval and output in your layout script.
15 The <classname>HeadLink</classname> helper has special methods for adding
16 stylesheet links to its stack:
22 <command>appendStylesheet($href, $media, $conditionalStylesheet, $extras)</command>
28 <command>offsetSetStylesheet($index, $href, $media, $conditionalStylesheet,
35 <command>prependStylesheet($href, $media, $conditionalStylesheet, $extras)</command>
41 <command>setStylesheet($href, $media, $conditionalStylesheet, $extras)</command>
47 The <varname>$media</varname> value defaults to 'screen', but may be any valid
48 media value. <varname>$conditionalStylesheet</varname> is a string or boolean
49 <constant>FALSE</constant>, and will be used at rendering time to determine if special
50 comments should be included to prevent loading of the stylesheet on certain platforms.
51 <varname>$extras</varname> is an array of any extra values that you want to be added
56 Additionally, the <classname>HeadLink</classname> helper has special methods for
57 adding 'alternate' links to its stack:
63 <command>appendAlternate($href, $type, $title, $extras)</command>
69 <command>offsetSetAlternate($index, $href, $type, $title, $extras)</command>
75 <command>prependAlternate($href, $type, $title, $extras)</command>
81 <command>setAlternate($href, $type, $title, $extras)</command>
87 The <methodname>headLink()</methodname> helper method allows specifying all
88 attributes necessary for a <emphasis><link></emphasis> element, and allows
89 you to also specify placement -- whether the new element replaces all
90 others, prepends (top of stack), or appends (end of stack).
94 The <classname>HeadLink</classname> helper is a concrete implementation of the
95 <link linkend="zend.view.helpers.initial.placeholder">Placeholder
99 <example id="zend.view.helpers.initial.headlink.basicusage">
100 <title>HeadLink Helper Basic Usage</title>
103 You may specify a <emphasis>headLink</emphasis> at any time. Typically, you
104 will specify global links in your layout script, and application
105 specific links in your application view scripts. In your layout
106 script, in the <head> section, you will then echo the helper
110 <programlisting language="php"><![CDATA[
111 <?php // setting links in a view script:
112 $this->headLink()->appendStylesheet('/styles/basic.css')
113 ->headLink(array('rel' => 'favicon',
114 'href' => '/img/favicon.ico'),
116 ->prependStylesheet('/styles/moz.css',
119 array('id' => 'my_stylesheet'));
121 <?php // rendering the links: ?>
122 <?php echo $this->headLink() ?>