Zend Framework 2
stable
  • Overview
  • Installation
  • Getting Started with Zend Framework 2
  • Getting started: A skeleton application
  • Modules
  • Routing and controllers
  • Database and models
  • Styling and Translations
  • Forms and actions
  • Conclusion
  • Learning Dependency Injection
  • Introduction
  • Database Table Authentication
  • Digest Authentication
  • HTTP Authentication Adapter
  • LDAP Authentication
  • Introduction
  • Barcode creation using Zend\Barcode\Barcode class
  • Zend\Barcode\Barcode Objects
  • Description of shipped barcodes
  • Zend\Barcode Renderers
  • Zend\Cache\Storage\Adapter
  • Zend\Cache\Storage\Capabilities
  • Zend\Cache\Storage\Plugin
  • Zend\Cache\Pattern
  • Introduction
  • Captcha Operation
  • CAPTCHA Adapters
  • Introduction
  • Theory of Operation
  • Zend\Config\Reader
  • Zend\Config\Writer
  • Zend\Config\Processor
  • Introduction
  • Encrypt/decrypt using block ciphers
  • Key derivation function
  • Password secure storing
  • Public key cryptography
  • Zend\Db\Adapter
  • Zend\Db\ResultSet
  • Zend\Db\Sql
  • Zend\Db\TableGateway
  • Zend\Db\RowGateway
  • Zend\Db\Metadata
  • Introduction to Zend\Di
  • Zend\Di Quickstart
  • Zend\Di Definition
  • Zend\Di InstanceManager
  • Zend\Di Configuration
  • Zend\Di Debugging & Complex Use Cases
  • Introduction
  • Zend\Dom\Query
  • The EventManager
  • Introduction to Zend\Form
  • Form Quick Start
  • Form Collections
  • Form Elements
  • Form View Helpers
  • Zend\Http
  • Zend\Http\Request
  • Zend\Http\Response
  • Zend\Http\Headers And The Various Header Classes
  • Zend_Http_Cookie and Zend_Http_CookieJar
  • Zend\Http\Client
  • Zend_Http_Client - Connection Adapters
  • Zend_Http_Client - Advanced Usage
  • Translating
  • I18n View Helpers
  • I18n Filters
  • Alnum Filter
  • Alpha Filter
  • NumberFormat Filter
  • Introduction
  • Introduction
  • API overview
  • Zend\Ldap\Ldap
  • Zend\Ldap\Attribute
  • Zend\Ldap\Converter\Converter
  • Zend\Ldap\Dn
  • Zend\Ldap\Filter
  • Zend\Ldap\Node
  • Zend\Ldap\Node\RootDse
  • Zend\Ldap\Node\Schema
  • Zend\Ldap\Ldif\Encoder
  • Usage Scenarios
  • Tools
  • Object oriented access to the LDAP tree using Zend\Ldap\Node
  • Getting information from the LDAP server
  • Serializing LDAP data to and from LDIF
  • The AutoloaderFactory
  • The PluginClassLoader
  • The ShortNameLocator Interface
  • The PluginClassLocator interface
  • The SplAutoloader Interface
  • The ClassMapAutoloader
  • The StandardAutoloader
  • The Class Map Generator utility: bin/classmap_generator.php
  • The PrefixPathLoader
  • The PrefixPathMapper Interface
  • Overview
  • Writers
  • Filters
  • Formatters
  • Zend\Mail\Message
  • Zend\Mail\Transport
  • Zend\Mail\Transport\SmtpOptions
  • Zend\Mail\Transport\FileOptions
  • Introduction
  • Introduction to the Module System
  • The Module Manager
  • The Module Class
  • The Module Autoloader
  • Best Practices when Creating Modules
  • Introduction to the MVC Layer
  • Quick Start
  • Default Services
  • Routing
  • The MvcEvent
  • Available Controllers
  • Controller Plugins
  • Examples
  • Introduction
  • Refining Access Controls
  • Advanced Usage
  • Zend\ServiceManager
  • Zend\ServiceManager Quick Start
  • Zend\Stdlib\Hydrator
  • Zend\Uri
  • Introduction
  • Standard Validation Classes
  • Alnum
  • Alpha
  • Barcode
  • Between
  • Callback
  • CreditCard
  • Date
  • Db\RecordExists and Db\NoRecordExists
  • Digits
  • EmailAddress
  • Float
  • GreaterThan
  • Hex
  • Hostname
  • Iban
  • Identical
  • InArray
  • Int
  • Ip
  • Isbn
  • LessThan
  • NotEmpty
  • PostCode
  • Regex
  • Sitemap Validators
  • Step
  • StringLength
  • Validator Chains
  • Writing Validators
  • Validation Messages
  • Zend\View Quick Start
  • The PhpRenderer
  • PhpRenderer View Scripts
  • View Helpers
  • Action View Helper
  • BaseUrl Helper
  • Cycle Helper
  • Partial Helper
  • Placeholder Helper
  • Doctype Helper
  • HeadLink Helper
  • HeadMeta Helper
  • HeadScript Helper
  • HeadStyle Helper
  • HeadTitle Helper
  • HTML Object Helpers
  • InlineScript Helper
  • JSON Helper
  • Navigation Helpers
  • Introduction
  • Zend\XmlRpc\Client
  • Zend\XmlRpc\Server
  • ZendService\LiveDocx
  • Copyright Information
Zend Framework 2
  • Docs »
  • HeadLink Helper
  • Edit on GitHub

HeadLink HelperΒΆ

The HTML <link> element is increasingly used for linking a variety of resources for your site: stylesheets, feeds, favicons, trackbacks, and more. The HeadLink helper provides a simple interface for creating and aggregating these elements for later retrieval and output in your layout script.

The HeadLink helper has special methods for adding stylesheet links to its stack:

  • appendStylesheet($href, $media, $conditionalStylesheet, $extras)
  • offsetSetStylesheet($index, $href, $media, $conditionalStylesheet, $extras)
  • prependStylesheet($href, $media, $conditionalStylesheet, $extras)
  • setStylesheet($href, $media, $conditionalStylesheet, $extras)

The $media value defaults to ‘screen’, but may be any valid media value. $conditionalStylesheet is a string or boolean FALSE, and will be used at rendering time to determine if special comments should be included to prevent loading of the stylesheet on certain platforms. $extras is an array of any extra values that you want to be added to the tag.

Additionally, the HeadLink helper has special methods for adding ‘alternate’ links to its stack:

  • appendAlternate($href, $type, $title, $extras)
  • offsetSetAlternate($index, $href, $type, $title, $extras)
  • prependAlternate($href, $type, $title, $extras)
  • setAlternate($href, $type, $title, $extras)

The headLink() helper method allows specifying all attributes necessary for a <link> element, and allows you to also specify placement – whether the new element replaces all others, prepends (top of stack), or appends (end of stack).

The HeadLink helper is a concrete implementation of the Placeholder helper.

HeadLink Helper Basic Usage

You may specify a headLink 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.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
<?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() ?>

© Copyright 2012, Zend Technologies Ltd.. Revision cbdae68d.

Built with Sphinx using a theme provided by Read the Docs.
Edit this document

Edit this document

The source code of this file is hosted on GitHub. Everyone can update and fix errors in this document with few clicks - no downloads needed.

  1. Go to HeadLink Helper on GitHub.
  2. Edit file contents using GitHub's text editor in your web browser
  3. Fill in the Commit message text box at the end of the page telling why you did the changes. Press Propose file change button next to it when done.
  4. On Send a pull request page you don't need to fill in text anymore. Just press Send pull request button.
  5. Your changes are now queued for review under project's Pull requests tab on GitHub.