Class HtmlHelper
Html Helper class for easy use of HTML widgets.
HtmlHelper encloses all methods needed while working with HTML pages.
- AppHelper
-
HtmlHelper
Link: http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html
Copyright: Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
License: MIT License
Location: Cake/View/Helper/HtmlHelper.php
Properties summary
-
$_crumbs
protectedarray
Breadcrumbs. -
$_docTypes
protectedarray
Document type definitions -
$_includedAssets
protectedarray
Names of script & css files that have been included once -
$_scriptBlockOptions
protectedarray
Options for the currently opened script block buffer if any. -
$_tags
protectedarray
html tags used by this helper. -
$response
publicReference to the Response object
Method Summary
-
__construct() public
Constructor -
_nestedListItem() protected
Internal function to build a nested list (UL/OL) out of an associative array. -
_prepareCrumbs() protected
Prepends startText to crumbs array if set -
addCrumb() public
Adds a link to the breadcrumbs array. -
charset() public
Returns a charset META-tag. -
css() public
Creates a link element for CSS stylesheets. -
div() public
Returns a formatted DIV tag for HTML FORMs. -
docType() public
Returns a doctype string. -
getCrumbList() public
Returns breadcrumbs as a (x)html list -
getCrumbs() public
Returns the breadcrumb trail as a sequence of »-separated links. -
image() public
Creates a formatted IMG element. -
link() public
Creates an HTML link. -
loadConfig() public
Load Html tag configuration. -
media() public
Returns an audio/video element -
meta() public
Creates a link to an external resource and handles basic meta tags -
nestedList() public
Build a nested list (UL/OL) out of an associative array. -
para() public
Returns a formatted P tag. -
script() public
Returns one or many<script>
tags depending on the number of scripts given. -
scriptBlock() public
Wrap $script in a script tag. -
scriptEnd() public
End a Buffered section of JavaScript capturing. Generates a script tag inline or in
$scripts_for_layout
depending on the settings used when the scriptBlock was started -
scriptStart() public
Begin a script block that captures output until HtmlHelper::scriptEnd() is called. This capturing block will capture all output between the methods and create a scriptBlock from it.
-
style() public
Builds CSS style data from an array of CSS properties -
tableCells() public
Returns a formatted string of table rows (TR's with TD's in them). -
tableHeaders() public
Returns a row of formatted and named TABLE headers. -
tag() public
Returns a formatted block tag, i.e DIV, SPAN, P. -
useTag() public
Returns a formatted existent block of $tags
Method Detail
__construct() public ¶
__construct( View
$View , array $settings = array() )
Constructor
Settings
configFile
A file containing an array of tags you wish to redefine.
Customizing tag sets
Using the configFile
option you can redefine the tag HtmlHelper will use.
The file named should be compatible with HtmlHelper::loadConfig().
Parameters
-
View
$View - The View this helper is being attached to.
- array $settings optional array()
- Configuration settings for the helper.
_nestedListItem() protected ¶
_nestedListItem( array $items , array $options , array $itemOptions , string $tag )
Internal function to build a nested list (UL/OL) out of an associative array.
Parameters
- array $items
- Set of elements to list
- array $options
- Additional HTML attributes of the list (ol/ul) tag
- array $itemOptions
- Additional HTML attributes of the list item (LI) tag
- string $tag
- Type of list tag to use (ol/ul)
Returns
The nested list element
See
_prepareCrumbs() protected ¶
_prepareCrumbs( string $startText , boolean $escape = true )
Prepends startText to crumbs array if set
Parameters
- string $startText
- Text to prepend
- boolean $escape optional true
- If the output should be escaped or not
Returns
Crumb list including startText (if provided)
addCrumb() public ¶
addCrumb( string $name , string $link = null , string|array $options = null )
Adds a link to the breadcrumbs array.
Parameters
- string $name
- Text for link
- string $link optional null
- URL for link (if empty it won't be a link)
- string|array $options optional null
- Link attributes e.g. array('id' => 'selected')
Returns
$this
See
Link
charset() public ¶
charset( string $charset = null )
Returns a charset META-tag.
Parameters
- string $charset optional null
The character set to be used in the meta tag. If empty, The App.encoding value will be used. Example: "utf-8".
Returns
A meta tag containing the specified character set.
Link
css() public ¶
css( string|array $path , array $options = array() )
Creates a link element for CSS stylesheets.
Usage
Include one CSS file:
echo $this->Html->css('styles.css');
Include multiple CSS files:
echo $this->Html->css(array('one.css', 'two.css'));
Add the stylesheet to the $scripts_for_layout
layout var:
$this->Html->css('styles.css', array('inline' => false));
Add the stylesheet to a custom block:
$this->Html->css('styles.css', array('block' => 'layoutCss'));
Options
inline
If set to false, the generated tag will be appended to the 'css' block, and included in the$scripts_for_layout
layout variable. Defaults to true.once
Whether or not the css file should be checked for uniqueness. If true css files will only be included once, use false to allow the same css to be included more than once per request.block
Set the name of the block link/style tag will be appended to. This overrides theinline
option.plugin
False value will prevent parsing path as a pluginrel
Defaults to 'stylesheet'. If equal to 'import' the stylesheet will be imported.fullBase
If true the URL will get a full address for the css file.
Parameters
- string|array $path
The name of a CSS style sheet or an array containing names of CSS stylesheets. If
$path
is prefixed with '/', the path will be relative to the webroot of your application. Otherwise, the path will be relative to your CSS path, usually webroot/css.- array $options optional array()
- Array of options and HTML arguments.
Returns
CSS or