Class HtmlHelper
Html Helper class for easy use of HTML widgets.
HtmlHelper encloses all methods needed while working with HTML pages.
Link: http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html
Copyright: Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
License: License (http://www.opensource.org/licenses/mit-license.php)
Location: Cake/View/Helper/HtmlHelper.php
Properties summary
-
$_attributeFormatprotectedstringFormat to attribute -
$_crumbsprotectedarrayBreadcrumbs. -
$_docTypesprotectedarrayDocument type definitions -
$_includedScriptsprotectedarrayNames of script files that have been included once -
$_minimizedAttributeFormatprotectedstringFormat to attribute -
$_minimizedAttributesprotectedarrayMinimized attributes -
$_scriptBlockOptionsprotectedarrayOptions for the currently opened script block buffer if any. -
$_tagsprotectedarrayhtml tags used by this helper.
Inherited Properties
Method Summary
-
__construct() public
Constructor -
_nestedListItem() protected
Internal function to build a nested list (UL/OL) out of an associative array. -
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. If
$options['url']is provided, an image link will be generated with the link pointed at$options['url']. This method will set an empty alt attribute if one is not supplied. -
link() public
Creates an HTML link. -
loadConfig() public
Load Html tag configuration. -
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_layoutdepending 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
configFileA 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.
Overrides
_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
addCrumb() public ¶
addCrumb( string $name , string $link = null , mixed $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)
- mixed $options optional null
- Link attributes e.g. array('id' => 'selected')
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( mixed $path , string $rel = null , 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', null, array('inline' => false));
Options
inlineIf set to false, the generated tag appears in the head tag of the layout. Defaults to true
Parameters
- mixed $path
The name of a CSS style sheet or an array containing names of CSS stylesheets. If
$pathis 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.- string $rel optional null
- Rel attribute. Defaults to "stylesheet". If equal to 'import' the stylesheet will be imported.
- array $options optional array()
- Array of HTML attributes.
Returns
CSS or