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