HtmlHelper Class Info:
- Class Declaration:
- class HtmlHelper extends AppHelper
- File name:
- cake/libs/view/helpers/html.php
- Summary:
- Html Helper class for easy use of HTML widgets. HtmlHelper encloses all methods needed while working with HTML pages.
- Class Inheritance
- package
- cake
- subpackage
- cake.cake.libs.view.helpers
Properties:
Show/Hide parent properties
| public | action | Current action. |
| public | argSeparator | URL argument separator character |
| public | base | Base URL |
| public | data | Enter description here... |
| public | helpers | List of helpers used by this helper |
| public | here | URL to current action. |
| protected | _log | Log object |
| public | namedArgs | List of named arguments |
| public | params | Parameter array. |
| public | plugin | Plugin path |
| public | tags | html tags used by this helper. |
| public | themeWeb | Theme name |
| public | validationErrors | Contains model validation errors of form post-backs |
| public | webroot | Webroot path |
Method Summary:
Show/Hide parent methods
addClass
topAdds the given class to the element options
- Parameters:
-
$options array optional array ( ) $class string optional NULL $key string optional 'class' - Method defined in class:
- Helper
- Method defined in file:
- cake/libs/view/helper.php on line 642
- return
- array
addCrumb
topAdds a link to the breadcrumbs array.
- Parameters:
-
$name string Text for link required (no default) $link string URL for link (if empty it won't be a link) optional NULL $options mixed Link attributes e.g. array('id'=>'selected') optional NULL - Method defined in class:
- HtmlHelper
- Method defined in file:
- cake/libs/view/helpers/html.php on line 164
afterLayout
topAfter layout callback. Overridden in subclasses.
- Method defined in class:
- Helper
- Method defined in file:
- cake/libs/view/helper.php on line 683
afterRender
topAfter render callback. Overridden in subclasses.
- Method defined in class:
- Helper
- Method defined in file:
- cake/libs/view/helper.php on line 671
beforeLayout
topBefore layout callback. Overridden in subclasses.
- Method defined in class:
- Helper
- Method defined in file:
- cake/libs/view/helper.php on line 677
beforeRender
topBefore render callback. Overridden in subclasses.
- Method defined in class:
- Helper
- Method defined in file:
- cake/libs/view/helper.php on line 665
cakeError
topUsed to report user friendly errors.
If there is a file app/error.php or app/app_error.php this file will be loaded
error.php is the AppError class it should extend ErrorHandler class.
- Parameters:
-
$method string Method to be called in the error class (AppError or ErrorHandler classes) required (no default) $messages array Message that is to be displayed by the error class optional array ( ) - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 189
- return
- error message
- access
- public
call__
top- Parameters:
-
$method required (no default) $params required (no default) - Method defined in class:
- Helper
- Method defined in file:
- cake/libs/view/helper.php on line 142
charset
topReturns a charset META-tag.
- Parameters:
-
$charset string The character set to be used in the meta tag. Example: "utf-8". optional NULL - Method defined in class:
- HtmlHelper
- Method defined in file:
- cake/libs/view/helpers/html.php on line 256
- return
- string A meta tag containing the specified character set.
clean
topUsed to remove harmful tags from content
- Parameters:
-
$output mixed required (no default) - Method defined in class:
- Helper
- Method defined in file:
- cake/libs/view/helper.php on line 214
- return
- cleaned content for output
- access
- public
__construct
topClass constructor, overridden in descendant classes.
- Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 63
css
topCreates a link element for CSS stylesheets.
- Parameters:
-
$path mixed 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. required (no default) $rel string Rel attribute. Defaults to "stylesheet". If equal to 'import' the stylesheet will be imported. optional NULL $htmlAttributes array Array of HTML attributes. optional array ( ) $inline boolean If set to false, the generated tag appears in the head tag of the layout. optional true - Method defined in class:
- HtmlHelper
- Method defined in file:
- cake/libs/view/helpers/html.php on line 326
- return
- string CSS <link /> or <style /> tag, depending on the type of link.
dispatchMethod
topCalls a method on this object with the given parameters. Provides an OO wrapper
for call_user_func_array, and improves performance by using straight method calls
in most cases.
- Parameters:
-
$method string Name of the method to call required (no default) $params array Parameter list to use when calling $method optional array ( ) - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 113
- return
- mixed Returns the result of the method call
- access
- public
div
topReturns a formatted DIV tag for HTML FORMs.
- Parameters:
-
$class string CSS class name of the div element. optional NULL $text string String content that will appear inside the div element. If null, only a start tag will be printed optional NULL $attributes array Additional HTML attributes of the DIV tag optional array ( ) $escape boolean If true, $text will be HTML-escaped optional false - Method defined in class:
- HtmlHelper
- Method defined in file:
- cake/libs/view/helpers/html.php on line 571
- return
- string The formatted DIV element
docType
topReturns a doctype string.
Possible doctypes:
+ html4-strict: HTML4 Strict.
+ html4-trans: HTML4 Transitional.
+ html4-frame: HTML4 Frameset.
+ xhtml-strict: XHTML1 Strict.
+ xhtml-trans: XHTML1 Transitional.
+ xhtml-frame: XHTML1 Frameset.
+ xhtml11: XHTML1.1.
- Parameters:
-
$type string Doctype to use. optional 'xhtml-strict' - Method defined in class:
- HtmlHelper
- Method defined in file:
- cake/libs/view/helpers/html.php on line 182
- return
- string Doctype.
domId
topGenerates a DOM ID for the selected element, if one is not set.
- Parameters:
-
$options mixed optional NULL $id string optional 'id' - Method defined in class:
- Helper
- Method defined in file:
- cake/libs/view/helper.php on line 483
- return
- mixed
field
topGets the currently-used model field of the rendering context.
- Method defined in class:
- Helper
- Method defined in file:
- cake/libs/view/helper.php on line 445
- return
- string
get__
topDefault overload methods
- Parameters:
-
$name required (no default) - Method defined in class:
- Helper
- Method defined in file:
- cake/libs/view/helper.php on line 140
- access
- protected
getCrumbs
topReturns the breadcrumb trail as a sequence of »-separated links.
- Parameters:
-
$separator string Text to separate crumbs. optional '»' $startText string This will be the first crumb, if false it defaults to first crumb in array optional false - Method defined in class:
- HtmlHelper
- Method defined in file:
- cake/libs/view/helpers/html.php on line 411
- return
- string
image
topCreates a formatted IMG element.
- Parameters:
-
$path string Path to the image file, relative to the app/webroot/img/ directory. required (no default) $options array Array of HTML attributes. optional array ( ) - Method defined in class:
- HtmlHelper
- Method defined in file:
- cake/libs/view/helpers/html.php on line 437
- return
- string
_initInputField
topSets the defaults for an input tag
- Parameters:
-
$field required (no default) $options array optional array ( ) - Method defined in class:
- Helper
- Method defined in file:
- cake/libs/view/helper.php on line 621
- return
- array
- access
- protected
link
topCreates an HTML link.
If $url starts with "http://" this is treated as an external link. Else,
it is treated as a path to controller/action and parsed with the
HtmlHelper::url() method.
If the $url is empty, $title is used instead.
- Parameters:
-
$title string The content to be wrapped by <a> tags. required (no default) $url mixed Cake-relative URL or array of URL parameters, or external URL (starts with http://) optional NULL $htmlAttributes array Array of HTML attributes. optional array ( ) $confirmMessage string JavaScript confirmation message. optional false $escapeTitle boolean Whether or not $title should be HTML escaped. optional true - Method defined in class:
- HtmlHelper
- Method defined in file:
- cake/libs/view/helpers/html.php on line 278
- return
- string An <a /> element.
loadConfig
topParses tag templates into $this->tags.
- Parameters:
-
$name optional 'tags' - Method defined in class:
- Helper
- Method defined in file:
- cake/libs/view/helper.php on line 152
- return
- array merged tags from config/$name.php
log
topAPI for logging events.
- Parameters:
-
$msg string Log message required (no default) $type integer Error type constant. Defined in app/config/core.php. optional 2 - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 150
- return
- boolean Success of log write
- access
- public
meta
topCreates a link to an external resource and handles basic meta tags
- Parameters:
-
$type string The title of the external resource required (no default) $url mixed The address of the external resource or string for content attribute optional NULL $attributes array Other attributes for the generated tag. If the type attribute is html, rss, atom, or icon, the mime-type is returned. optional array ( ) $inline boolean If set to false, the generated tag appears in the head tag of the layout. optional true - Method defined in class:
- HtmlHelper
- Method defined in file:
- cake/libs/view/helpers/html.php on line 197
- return
- string
model
topGets the currently-used model of the rendering context.
- Method defined in class:
- Helper
- Method defined in file:
- cake/libs/view/helper.php on line 423
- return
- string
modelID
topGets the ID of the currently-used model of the rendering context.
- Method defined in class:
- Helper
- Method defined in file:
- cake/libs/view/helper.php on line 436
- return
- mixed
__name
topGets the input field name for the current tag
- Parameters:
-
$options array optional array ( ) $field optional NULL $key string optional 'name' - Method defined in class:
- Helper
- Method defined in file:
- cake/libs/view/helper.php on line 510
- return
- array
nestedList
topBuild a nested list (UL/OL) out of an associative array.
- Parameters:
-
$list array Set of elements to list required (no default) $attributes array Additional HTML attributes of the list (ol/ul) tag or if ul/ol use that as tag optional array ( ) $itemAttributes array Additional HTML attributes of the list item (LI) tag optional array ( ) $tag string Type of list tag to use (ol/ul) optional 'ul' - Method defined in class:
- HtmlHelper
- Method defined in file:
- cake/libs/view/helpers/html.php on line 610
- return
- string The nested list
- access
- public
Object
topA hack to support __construct() on PHP 4
Hint: descendant classes have no PHP4 class_name() constructors,
so this constructor gets called first and calls the top-layer __construct()
which (if present) should call parent::__construct()
- Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 53
- return
- Object
output
topReturns a string generated by a helper method
This method can be overridden in subclasses to do generalized output post-processing
- Parameters:
-
$str string String to be output. required (no default) - Method defined in class:
- Helper
- Method defined in file:
- cake/libs/view/helper.php on line 658
- return
- string
overload
topOverload implementation. No need for implementation in PHP5.
- Method defined in class:
- Overloadable
- Method defined in file:
- cake/libs/overloadable_php5.php on line 39
- access
- public
para
topReturns a formatted P tag.
- Parameters:
-
$class string CSS class name of the p element. required (no default) $text string String content that will appear inside the p element. required (no default) $attributes array Additional HTML attributes of the P tag optional array ( ) $escape boolean If true, $text will be HTML-escaped optional false - Method defined in class:
- HtmlHelper
- Method defined in file:
- cake/libs/view/helpers/html.php on line 586
- return
- string The formatted P element
_parseAttributes
topReturns a space-delimited string with items of the $options array. If a
key of $options array happens to be one of:
+ 'compact'
+ 'checked'
+ 'declare'
+ 'readonly'
+ 'disabled'
+ 'selected'
+ 'defer'
+ 'ismap'
+ 'nohref'
+ 'noshade'
+ 'nowrap'
+ 'multiple'
+ 'noresize'
And its value is one of:
+ 1
+ true
+ 'true'
Then the value will be reset to be identical with key's name.
If the value is not one of these 3, the parameter is not output.
- Parameters:
-
$options array Array of options. required (no default) $exclude array Array of options to be excluded. optional NULL $insertBefore string String to be inserted before options. optional ' ' $insertAfter string String to be inserted ater options. optional NULL - Method defined in class:
- Helper
- Method defined in file:
- cake/libs/view/helper.php on line 260
- return
- string
_persist
topChecks for a persistent class file, if found file is opened and true returned
If file is not found a file is created and false returned
If used in other locations of the model you should choose a unique name for the persistent file
There are many uses for this method, see manual for examples
- Parameters:
-
$name string name of the class to persist required (no default) $return required (no default) $object string the object to persist required (no default) $type optional NULL - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 219
- return
- boolean Success
- access
- protected
- todo
- add examples to manual
requestAction
topCalls a controller's method from any location.
- Parameters:
-
$url mixed String or array-based url. required (no default) $extra array if array includes the key "return" it sets the AutoRender to true. optional array ( ) - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 86
- return
- mixed Boolean true or false on success/failure, or contents of rendered action if 'return' is set in $extra.
- access
- public
_savePersistent
topYou should choose a unique name for the persistent file
There are many uses for this method, see manual for examples
- Parameters:
-
$name string name used for object to cache required (no default) $object object the object to persist required (no default) - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 247
- return
- boolean true on save, throws error if file can not be created
- access
- protected
_set
topAllows setting of multiple properties of the object in a single line of code.
- Parameters:
-
$properties array An associative array containing properties and corresponding values. optional array ( ) - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 169
- return
- void
- access
- protected
set__
top- Parameters:
-
$name required (no default) $value required (no default) - Method defined in class:
- Helper
- Method defined in file:
- cake/libs/view/helper.php on line 141
setEntity
topSets this helper's model and field properties to the dot-separated value-pair in $entity.
- Parameters:
-
$entity mixed A field name, like "ModelName.fieldName" or "ModelName.ID.fieldName" required (no default) $setScope boolean Sets the view scope to the model specified in $tagValue optional false - Method defined in class:
- Helper
- Method defined in file:
- cake/libs/view/helper.php on line 311
- return
- void
_stop
topStop execution of the current script
- Parameters:
-
$status optional 0 - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 139
- return
- void
- access
- public
style
topBuilds CSS style data from an array of CSS properties
- Parameters:
-
$data array Style data array required (no default) $inline boolean Whether or not the style block should be displayed inline optional true - Method defined in class:
- HtmlHelper
- Method defined in file:
- cake/libs/view/helpers/html.php on line 391
- return
- string CSS styling data
tableCells
topReturns a formatted string of table rows (TR's with TD's in them).
- Parameters:
-
$data array Array of table data required (no default) $oddTrOptions array HTML options for odd TR elements if true useCount is used optional NULL $evenTrOptions array HTML options for even TR elements optional NULL $useCount bool adds class "column-$i" optional false $continueOddEven bool If false, will use a non-static $count variable, so that the odd/even count is reset to zero just for that call optional true - Method defined in class:
- HtmlHelper
- Method defined in file:
- cake/libs/view/helpers/html.php on line 496
- return
- string Formatted HTML
tableHeaders
topReturns a row of formatted and named TABLE headers.
- Parameters:
-
$names array Array of tablenames. required (no default) $trOptions array HTML options for TR elements. optional NULL $thOptions array HTML options for TH elements. optional NULL - Method defined in class:
- HtmlHelper
- Method defined in file:
- cake/libs/view/helpers/html.php on line 478
- return
- string
tag
topReturns a formatted block tag, i.e DIV, SPAN, P.
- Parameters:
-
$name string Tag name. required (no default) $text string String content that will appear inside the div element. If null, only a start tag will be printed optional NULL $attributes array Additional HTML attributes of the DIV tag optional array ( ) $escape boolean If true, $text will be HTML-escaped optional false - Method defined in class:
- HtmlHelper
- Method defined in file:
- cake/libs/view/helpers/html.php on line 547
- return
- string The formatted tag element
tagIsInvalid
topReturns false if given FORM field has no errors. Otherwise it returns the constant set in the array Model->validationErrors.
- Parameters:
-
$model string Model name as string optional NULL $field string Fieldname as string optional NULL $modelID integer Unique index identifying this record within the form optional NULL - Method defined in class:
- Helper
- Method defined in file:
- cake/libs/view/helper.php on line 457
- return
- boolean True on errors.
toString
topObject-to-string conversion.
Each class can override this method as necessary.
- Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 73
- return
- string The name of this class
- access
- public
url
topFinds URL for specified action.
Returns an URL pointing to a combination of controller and action. Param
$url can be:
+ Empty - the method will find adress to actuall controller/action.
+ '/' - the method will find base URL of application.
+ A combination of controller/action - the method will find url for it.
- Parameters:
-
$url mixed Cake-relative URL, like "/products/edit/92" or "/presidents/elect/4" or an array specifying any of the following: 'controller', 'action', and/or 'plugin', in addition to named arguments (keyed array elements), and standard URL arguments (indexed array elements) optional NULL $full boolean If true, the full base URL will be prepended to the result optional false - Method defined in class:
- Helper
- Method defined in file:
- cake/libs/view/helper.php on line 177
- return
- string Full translated URL with base path.
value
topGets the data for the current tag
- Parameters:
-
$options array optional array ( ) $field optional NULL $key string optional 'value' - Method defined in class:
- Helper
- Method defined in file:
- cake/libs/view/helper.php on line 552
- return
- array
- access
- public
webroot
topChecks if a file exists when theme is used, if no file is found default location is returned
- Parameters:
-
$file string required (no default) - Method defined in class:
- Helper
- Method defined in file:
- cake/libs/view/helper.php on line 186
- return
- string $webPath web path to file.