<?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>&lt;link&gt;</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>&lt;link&gt;</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 &lt;head&gt; 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:
-->
