Zend Framework 2
latest
  • Overview
  • Installation
  • Getting Started with Zend Framework 2
  • Getting started: A skeleton application
  • Modules
  • Routing and controllers
  • Create the controller
  • Database and models
  • Styling and Translations
  • Forms and actions
  • Conclusion
  • Zend Framework Tool (ZFTool)
  • Learning Dependency Injection
  • Unit Testing a Zend Framework 2 application
  • Using the EventManager
  • Wildcards
  • Listener aggregates
  • Advanced Configuration Tricks
  • Using Zend\Navigation in your Album Module
  • Using Zend\Paginator in your Album Module
  • Using the PaginationControl View Helper
  • Setting up a database adapter
  • Migration from Zend Framework 1
  • Namespacing Old Classes
  • Running Zend Framework 2 and Zend Framework 1 in parallel
  • Introduction to Zend\Authentication
  • Database Table Authentication
  • Digest Authentication
  • HTTP Authentication Adapter
  • LDAP Authentication
  • Authentication Validator
  • Introduction to Zend\Barcode
  • Barcode creation using Zend\Barcode\Barcode class
  • Zend\Barcode\Barcode Objects
  • Zend\Barcode Renderers
  • Zend\Cache\Storage\Adapter
  • Zend\Cache\Storage\Capabilities
  • Zend\Cache\Storage\Plugin
  • Zend\Cache\Pattern
  • Zend\Cache\Pattern\CallbackCache
  • Zend\Cache\Pattern\ClassCache
  • Zend\Cache\Pattern\ObjectCache
  • Zend\Cache\Pattern\OutputCache
  • Zend\Cache\Pattern\CaptureCache
  • Introduction to Zend\Captcha
  • Captcha Operation
  • CAPTCHA Adapters
  • Introduction to Zend\Config
  • Theory of Operation
  • Zend\Config\Reader
  • Zend\Config\Writer
  • Zend\Config\Processor
  • The Factory
  • Introduction to Zend\Console
  • Console routes and routing
  • Console-aware modules
  • Console-aware action controllers
  • Console adapters
  • Console prompts
  • Introduction to Zend\Crypt
  • Encrypt/decrypt using block ciphers
  • Key derivation function
  • Password
  • Public key cryptography
  • Zend\Db\Adapter
  • Zend\Db\ResultSet
  • Zend\Db\Sql
  • Zend\Db\Sql\Ddl
  • Creating Tables
  • Altering Tables
  • Dropping Tables
  • Executing DDL Statements
  • Currently Supported Data Types
  • Currently Supported Constraint Types
  • 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 to Zend\Dom
  • Zend\Dom\Query
  • Introduction to Zend\Escaper
  • Theory of Operation
  • Configuring Zend\Escaper
  • Escaping HTML
  • Escaping HTML Attributes
  • Escaping Javascript
  • Escaping Cascading Style Sheets
  • Escaping URLs
  • The EventManager
  • Introduction to Zend\Feed
  • Importing Feeds
  • Retrieving Feeds from Web Pages
  • Consuming an RSS Feed
  • Consuming an Atom Feed
  • Consuming a Single Atom Entry
  • Zend\Feed and Security
  • Zend\Feed\Reader\Reader
  • Zend\Feed\Writer\Writer
  • Zend\Feed\PubSubHubbub
  • Zend\File\ClassFileLocator
  • Introduction to Zend\Filter
  • Using the StaticFilter
  • Standard Filter Classes
  • Word Filters
  • File Filter Classes
  • Filter Chains
  • Zend\Filter\Inflector
  • Writing Filters
  • Introduction to Zend\Form
  • Form Quick Start
  • Form Collections
  • File Uploading
  • Advanced use of forms
  • Form Elements
  • Form View Helpers
  • Overview of Zend\Http
  • The Request Class
  • The Response Class
  • The Headers Class
  • HTTP Client - Overview
  • HTTP Client - Connection Adapters
  • HTTP Client - Advanced Usage
  • HTTP Client - Static Usage
  • Translating
  • I18n View Helpers
  • I18n Filters
  • I18n Validators
  • Float
  • Int
  • Introduction to Zend\InputFilter
  • File Upload Input
  • Introduction to Zend\Json
  • Basic Usage
  • Advanced Usage of Zend\Json
  • XML to JSON conversion
  • Zend\Json\Server - JSON-RPC server
  • Introduction to Zend\Ldap
  • 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 StandardAutoloader
  • The ClassMapAutoloader
  • The ModuleAutoloader
  • The SplAutoloader Interface
  • The PluginClassLoader
  • The ShortNameLocator Interface
  • The PluginClassLocator interface
  • The Class Map Generator utility: bin/classmap_generator.php
  • Overview of Zend\Log
  • Writers
  • Filters
  • Formatters
  • Introduction to Zend\Mail
  • Zend\Mail\Message
  • Zend\Mail\Transport
  • Zend\Mail\Transport\SmtpOptions
  • Zend\Mail\Transport\FileOptions
  • Introduction to Zend\Math
  • Zend\Mime
  • Zend\Mime\Message
  • Zend\Mime\Part
  • 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
  • The SendResponseEvent
  • Available Controllers
  • Controller Plugins
  • Examples
  • Introduction to Zend\Navigation
  • Quick Start
  • Pages
  • Common page features
  • Zend\Navigation\Page\Mvc
  • Zend\Navigation\Page\Uri
  • Creating custom page types
  • Creating pages using the page factory
  • Containers
  • View Helpers
  • View Helper - Breadcrumbs
  • View Helper - Links
  • View Helper - Menu
  • View Helper - Sitemap
  • View Helper - Navigation Proxy
  • Introduction to Zend\Paginator
  • Usage
  • Configuration
  • Advanced usage
  • Introduction to Zend\Permissions\Acl
  • Refining Access Controls
  • Advanced Usage
  • Introduction to Zend\Permissions\Rbac
  • Methods
  • Examples
  • Progress Bars
  • File Upload Handlers
  • Introduction to Zend\Serializer
  • Zend\Serializer\Adapter
  • Introduction to Zend\Server
  • Zend\Server\Reflection
  • Zend\ServiceManager
  • Zend\ServiceManager Quick Start
  • Delegator service factories
  • Lazy Services
  • Session Config
  • Session Container
  • Session Manager
  • Session Save Handlers
  • Session Storage
  • Session Validators
  • Zend\Soap\Server
  • Zend\Soap\Client
  • WSDL Accessor
  • AutoDiscovery
  • Zend\Stdlib\Hydrator
  • Zend\Stdlib\Hydrator\Filter
  • Zend\Stdlib\Hydrator\Strategy
  • Zend\Stdlib\Hydrator\Aggregate\AggregateHydrator
  • Introduction to Zend\Tag
  • Creating tag clouds with Zend\Tag\Cloud
  • Introduction to Zend\Test
  • Unit testing with PHPUnit
  • Setup your TestCase
  • Testing your Controllers and MVC Applications
  • Assertions
  • Request Assertions
  • CSS Selector Assertions
  • XPath Assertions
  • Redirect Assertions
  • Response Header Assertions
  • Zend\Text\Figlet
  • Zend\Text\Table
  • Zend\Uri
  • Introduction to Zend\Validator
  • Standard Validation Classes
  • Alnum
  • Alpha
  • Barcode
  • Between
  • Callback
  • CreditCard
  • Date
  • Db\RecordExists and Db\NoRecordExists
  • Digits
  • EmailAddress
  • File Validation Classes
  • Float
  • GreaterThan
  • Hex
  • Hostname
  • Iban
  • Identical
  • InArray
  • Ip
  • Isbn
  • LessThan
  • NotEmpty
  • PostCode
  • Regex
  • Sitemap Validators
  • Step
  • StringLength
  • File Validation Classes
  • Validator Chains
  • Writing Validators
  • Validation Messages
  • Getting the Zend Framework Version
  • Zend\View Quick Start
  • The PhpRenderer
  • PhpRenderer View Scripts
  • The ViewEvent
  • View Helpers
  • View Helper - BasePath
  • View Helper - Cycle
  • View Helper - Doctype
  • FlashMessenger Helper
  • View Helper - HeadLink
    • Introduction
    • Basic Usage
  • View Helper - HeadMeta
  • View Helper - HeadScript
  • View Helper - HeadStyle
  • View Helper - HeadTitle
  • View Helper - HtmlList
  • View Helper - HTML Object
  • View Helper - Identity
  • View Helper - InlineScript
  • View Helper - JSON
  • View Helper - Partial
  • View Helper - Placeholder
  • View Helper - URL
  • Advanced usage of helpers
  • Introduction to Zend\XmlRpc
  • Zend\XmlRpc\Client
  • Zend\XmlRpc\Server
  • ZendService\Akismet
  • ZendService\Amazon
  • ZendService\Apple\Apns
  • ZendService\Audioscrobbler
  • ZendService\Delicious
  • ZendServiceDeveloperGardenDeveloperGarden
  • ZendService\Flickr
  • ZendService\Google\Gcm
  • ZendService\LiveDocx\LiveDocx
  • ZendService\Nirvanix
  • Zend\Service\Rackspace
  • ZendService\ReCaptcha
  • ZendService\SlideShare
  • ZendService\StrikeIron
  • ZendService\StrikeIron: Bundled Services
  • ZendService\StrikeIron: Advanced Uses
  • ZendService\Technorati
  • ZendService\Twitter
  • ZendService\WindowsAzure
  • ZendService\WindowsAzure\Storage\Blob
  • ZendService\WindowsAzure\Storage\Table
  • ZendService\WindowsAzure\StorageQueue
  • Copyright Information
Zend Framework 2
  • Docs »
  • View Helper - HeadLink
  • Edit on GitHub

View Helper - HeadLink¶

Introduction¶

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.

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
13
14
15
<?php // setting links in a view script:
$this->headLink(array(
    'rel'  => 'favicon',
    'href' => '/img/favicon.ico',
), 'PREPEND')
    ->appendStylesheet('/styles/basic.css')
    ->prependStylesheet(
        '/styles/moz.css',
        'screen',
        true,
        array('id' => 'my_stylesheet')
    );
?>
<?php // rendering the links: ?>
<?php echo $this->headLink() ?>
Next Previous

© Copyright 2013, Zend Technologies Ltd.. Revision 4e53a6a5.

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. Login with your GitHub account.
  2. Go to View Helper - HeadLink on GitHub.
  3. Edit file contents using GitHub's text editor in your web browser
  4. 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.
  5. On Send a pull request page you don't need to fill in text anymore. Just press Send pull request button.
  6. Your changes are now queued for review under project's Pull requests tab on GitHub.