Final Class Yiisoft\Bootstrap5\BreadcrumbLink
| Inheritance | Yiisoft\Bootstrap5\BreadcrumbLink |
|---|
BreadcrumbLink represents a single breadcrumb navigation link.
Each link can be either active or inactive, and can be rendered as a plain text (when active) or as a hyperlink (when inactive).
Example:
`php
// Create a standard link
BreadcrumbLink::to('Home', '/');
// Create an active link (current page) BreadcrumbLink::to('Current Page', null, true);
// Create a link with custom attributes
BreadcrumbLink::to('Link', '/path', false, ['class' => 'custom-link']);
`
Public Methods
| Method | Description | Defined By |
|---|---|---|
| active() | Sets the active state. | Yiisoft\Bootstrap5\BreadcrumbLink |
| attributes() | Sets the HTML attributes for the link. | Yiisoft\Bootstrap5\BreadcrumbLink |
| encodeLabel() | Sets whether to HTML encode the label. | Yiisoft\Bootstrap5\BreadcrumbLink |
| getAttributes() | Yiisoft\Bootstrap5\BreadcrumbLink | |
| getLabel() | Yiisoft\Bootstrap5\BreadcrumbLink | |
| getUrl() | Yiisoft\Bootstrap5\BreadcrumbLink | |
| isActive() | Yiisoft\Bootstrap5\BreadcrumbLink | |
| label() | Sets the label text to display. | Yiisoft\Bootstrap5\BreadcrumbLink |
| to() | Creates a new {@see BreadcrumbLink} instance. | Yiisoft\Bootstrap5\BreadcrumbLink |
| url() | Sets the URL for the link. | Yiisoft\Bootstrap5\BreadcrumbLink |
Method Details
Sets the active state.
| public self active ( boolean $enabled ) | ||
| $enabled | boolean |
Whether the breadcrumb link is active. |
| return | self |
A new instance with the specified active state. |
|---|---|---|
public function active(bool $enabled): self
{
$new = clone $this;
$new->active = $enabled;
return $new;
}
Sets the HTML attributes for the link.
| public self attributes ( array $attributes ) | ||
| $attributes | array |
Attribute values indexed by attribute names. |
| return | self |
A new instance with the specified attributes. |
|---|---|---|
public function attributes(array $attributes): self
{
$new = clone $this;
$new->attributes = $attributes;
return $new;
}
Sets whether to HTML encode the label.
| public self encodeLabel ( boolean $enabled ) | ||
| $enabled | boolean |
Whether to HTML encode the label. |
| return | self |
A new instance with the specified encoding behavior. |
|---|---|---|
public function encodeLabel(bool $enabled): self
{
$new = clone $this;
$new->encodeLabel = $enabled;
return $new;
}
| public array getAttributes ( ) | ||
| return | array |
The HTML attributes for the link. |
|---|---|---|
public function getAttributes(): array
{
return $this->attributes;
}
| public string getLabel ( ) | ||
| return | string |
The encoded label content. For default behavior, the label will be HTML-encoded. You can
disable this by setting |
|---|---|---|
public function getLabel(): string
{
return $this->encodeLabel ? Html::encode($this->label) : $this->label;
}
| public string|null getUrl ( ) | ||
| return | string|null |
The URL for the link. |
|---|---|---|
public function getUrl(): string|null
{
return $this->url;
}
| public boolean isActive ( ) | ||
| return | boolean |
Whether the item is active. |
|---|---|---|
public function isActive(): bool
{
return $this->active;
}
Sets the label text to display.
| public self label ( string $label ) | ||
| $label | string |
The label text to display. |
| return | self |
A new instance with the specified label. |
|---|---|---|
public function label(string $label): self
{
$new = clone $this;
$new->label = $label;
return $new;
}
Creates a new {@see BreadcrumbLink} instance.
| public static self to ( string $label, string|null $url = null, boolean $active = false, array $attributes = [], boolean $encodeLabel = true ) | ||
| $label | string |
The label text to display. |
| $url | string|null |
The URL for the link. |
| $active | boolean |
Whether this link represents the current page. |
| $attributes | array |
Additional HTML attributes for the link. |
| $encodeLabel | boolean |
Whether to HTML encode the label. |
| return | self |
A new instance with the specified configuration. |
|---|---|---|
public static function to(
string $label,
string|null $url = null,
bool $active = false,
array $attributes = [],
bool $encodeLabel = true
): self {
return new self($label, $url, $active, $encodeLabel, $attributes);
}
Signup or Login in order to comment.