The Html factory provides standard objects which represent the elements available as part of the Hypertext Markup Language. These objects are not to be confused with the Html helper available in CakePHP, for this check out the Cake factory.
To use the Html factory in a View include it in the $factories property of the CTK class, for example:
public $factories = array('Ctk.Html');
Once the factory is available you can access the objects it provides. To call an object from the factory simply call the factory, and then the desired object, for example:
$this->Html->Div(array(
'text' => __('Hello World')
));
As shown in the example, an array can be passed to the object with parameters to configure the object's template.
The objects available in the Html factory are the following:
- A - Object representing the A element for hyperlinks.
- Abbr - Object representing the ABBR element for abbreviations.
- Address - Object representing the ADDRESS element for contact addresses.
- Area - Object representing the Area element for an area of an image map.
- B - Object representing the B element for bold text.
- Base - Object representing the BASE element for base target for relative URLs.
- Bdo - Object representing the BDO element for bi-directional override.
- Blockquote - Object representing the BLOCKQUOTE element for block quotes.
- Body - Object representing the BODY element.
- Br - Object representing the BR element for line breaks.
- Button - Object representing the BUTTON element for form buttons. Use the Cake factory for CakePHP forms.
- Caption - Object representing the CAPTION element for table captions.
- Cite - Object representing the CITE element for citations.
- Code - Object representing the CODE element for code blocks.
- Col - Object representing the COL element for tbale column properties.
- Colgroup - Object representing the COLGROUP element for groups of table columns.
- Comment - Object representing the comment element.
- Dd - Object representing the DD element for definition descriptions.
- Del - Object representing the DEL element for deleted text.
- Dfn - Object representing the DFN element for a definition term.
- Div - Object representing the DIV element for a block of content.
- Dl - Object representing the DL element for definition lists.
- Doctype - Object representing the document type.
- Dt - Object representing the DT element for definition terms.
- Element - Base object for all HTML elements.
- Em - Object representing the EM element for text with emphasis.
- Fieldset - Object representing the FIELDSET element in forms. Use the Cake factory for CakePHP forms.
- Form - Object representing the FORM element. Use the Cake factory for CakePHP forms.
- H - Object representing the base header element.
- H1 - Object representing the H1 header element.
- H2 - Object representing the H2 header element.
- H3 - Object representing the H3 header element.
- H4 - Object representing the H4 header element.
- H5 - Object representing the H5 header element.
- H6 - Object representing the H6 header element.
- Head - Object representing the HEAD element.
- Hr - Object representing the HR element for horizontal rules.
- Html - Object representing the root HTML element.
- I - Object representing the I element for italics.
- Iframe - Object representing the IFRAME element for containing another document.
- Img - Object representing the IMG element for images.
- Input - Object representing the INPUT element for form inputs. Use the Cake factory for CakePHP forms.
- Ins - Object representing the INS element for inserted text.
- Kbd - Object representing the KBD element for keyboard input.
- Label - Object representing the LABEL element for form labels. Use the Cake factory for CakePHP forms.
- Legend - Object representing the LEGEND element for fieldsets. Use the Cake factory for CakePHP forms.
- Li - Object representing the LI element for list items.
- Link - Object representing the LINK element for linked resources.
- Map - Object representing the MAP element for image maps.
- Meta - Object representing the META element for meta content.
- Noscript - Object representing the NOSCRIPT element for when scripting is not available.
- Object - Object representing the OBJECT element for embedded objects.
- Ol - Object representing the OL element for ordered lists.
- Optgroup - Object representing the OPTGROUP element for groups of options in selects. Use the Cake factory for CakePHP forms.
- Option - Object representing the OPTION element for select options. Use the Cake factory for CakePHP forms.
- P - Object representing the P element for paragraphs.
- Param - Object representing the PARAM element for embedded objects.
- Pre - Object representing the PRE element for preformatted text.
- Q - Object representing the Q element for quoted text.
- S - Object representing the S element for stike-through text.
- Samp - Object representing the SAMP element for sample text.
- Script - Object representing the SCRIPT element for client scripts.
- Select - Object representing the SELECT element for selects. Use the Cake factory for CakePHP forms.
- Small - Object representing the SMALL element for small text.
- Span - Object representing the SPAN element for spanned text.
- Strong - Object representing the STRONG element for strong text.
- Style - Object representing the STYLE element for CSS styles.
- Sub - Object representing the SUB element for subscript.
- Sup - Object representing the SUP element for superscript.
- Table - Object representing the TABLE element for tables.
- Tbody - Object representing the TBODY element for table bodies.
- Td - Object representing the TD element for table cells.
- Textarea - Object representing the TEXTAREA element for textareas. Use the Cake factory for CakePHP forms.
- Tfoot - Object representing the TFOOT element for table footers.
- Th - Object representing the TH element for table headers.
- Thead - Object representing the THEAD element for table heads.
- Title - Object representing the TITLE element for document titles.
- Tr - Object representing the TR element for table rows.
- Ul - Object representing the UL element for unordered lists.
- Var - Object representing the VAR element for variables.
There are also various layouts available for this factory:
- default: This is the default layout used by CTK views.
- html4: A HTML 4.01 compatible layout.
- html5: A HTML 5 compatible layout.
- xhtml: An XHTML 1.0 compatible layout.
The layout can be set from the $layout property of the CTK class, for example:
public $layout = 'Ctk.Html/html5';