HTML Components¶
Overview¶
A common piece of HTML that is present in many web applications is the breadcrumbs. These are links separated by a space or by the /
character usually, that represent the tree structure of an application. The purpose is to give users another easy visual way to navigate throughout the application.
An example is an application that has an admin
module, an invoices
area, and a view invoice
page. Usually, you would select the admin
module, then from the links you will choose invoices
(list), and then clicking on one of the invoices in the list, you can view it. To represent this tree-like structure, the breadcrumbs displayed could be:
Phalcon\Html\Breadcrumbs offers functionality to add text and URLs. The resulting HTML when calling render()
will have each breadcrumb enclosed in <dt>
tags, while the whole string is enclosed in <dl>
tags.
Methods¶
Adds a new crumb.In the example below, add a crumb with a link and then add a crumb without a link (normally the last one)
Clears the crumbs Returns the separator used for the breadcrumbs Removes crumb by URL.In the example below remove a crumb by URL and also remove a crumb without an URL (last link)
Renders and outputs breadcrumb HTML. The template used is:<dl>
<dt><a href="Hyperlink">Text</a></dt> /
<dt><a href="Hyperlink">Text</a></dt> /
<dt>Text</dt>
</dl>
<dt></dt>
tags. The whole collection is wrapped in <dl></dl>
tags. You can use them in conjunction with CSS to format the crumbs on screen according to the needs of your application. The default separator between the crumbs is /
. You can set a different one if you wish using this method. Returns the internal breadcrumbs array