| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- <?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:
- -->
|