CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 5.1 Chiffon API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 5.1
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • Cache
    • Collection
    • Command
    • Console
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Form
    • Http
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
    • Utility
    • Validation
    • View
      • Exception
      • Form
      • Helper
      • Widget

Class BreadcrumbsHelper

BreadcrumbsHelper to register and display a breadcrumb trail for your views

Namespace: Cake\View\Helper

Property Summary

  • $Url public @property
    Cake\View\Helper\UrlHelper
  • $_View protected
    Cake\View\View

    The View instance this helper is attached to

  • $_config protected
    array<string, mixed>

    Runtime config

  • $_configInitialized protected
    bool

    Whether the config property has already been configured with defaults

  • $_defaultConfig protected
    array<string, mixed>

    Default config for the helper.

  • $_templater protected
    Cake\View\StringTemplate|null

    StringTemplate instance.

  • $crumbs protected
    array

    The crumb list.

  • $helperInstances protected
    array<string, \Cake\View\Helper>

    Loaded helper instances.

  • $helpers protected
    array

    Other helpers used by BreadcrumbsHelper.

Method Summary

  • __construct() public

    Default Constructor

  • __debugInfo() public

    Returns an array that can be used to describe the internal state of this object.

  • __get() public

    Lazy loads helpers.

  • _configDelete() protected

    Deletes a single config key.

  • _configRead() protected

    Reads a config key.

  • _configWrite() protected

    Writes a config key.

  • _confirm() protected

    Returns a string to be used as onclick handler for confirm dialogs.

  • add() public

    Add a crumb to the end of the trail.

  • addClass() public

    Adds the given class to the element options

  • configShallow() public

    Merge provided config with existing config. Unlike config() which does a recursive merge for nested keys, this method does a simple merge.

  • findCrumb() protected

    Search a crumb in the current stack which title matches the one provided as argument. If found, the index of the matching crumb will be returned.

  • formatTemplate() public

    Formats a template string with $data

  • getConfig() public

    Returns the config.

  • getConfigOrFail() public

    Returns the config for this specific key.

  • getCrumbs() public

    Returns the crumb list.

  • getTemplates() public

    Gets templates to use or a specific template.

  • getView() public

    Get the view instance this helper is bound to.

  • implementedEvents() public

    Get the View callbacks this helper is interested in.

  • initialize() public

    Constructor hook method.

  • insertAfter() public

    Insert a crumb after the first matching crumb with the specified title.

  • insertAt() public

    Insert a crumb at a specific index.

  • insertBefore() public

    Insert a crumb before the first matching crumb with the specified title.

  • prepend() public

    Prepend a crumb to the start of the queue.

  • render() public

    Renders the breadcrumbs trail.

  • reset() public

    Removes all existing crumbs.

  • setConfig() public

    Sets the config.

  • setTemplates() public

    Sets templates to use.

  • templater() public

    Returns the templater instance.

Method Detail

__construct() ¶ public

__construct(Cake\View\View $view, array<string, mixed> $config = [])

Default Constructor

Parameters
Cake\View\View $view

The View this helper is being attached to.

array<string, mixed> $config optional

Configuration settings for the helper.

__debugInfo() ¶ public

__debugInfo(): array<string, mixed>

Returns an array that can be used to describe the internal state of this object.

Returns
array<string, mixed>

__get() ¶ public

__get(string $name): Cake\View\Helper|null

Lazy loads helpers.

Parameters
string $name

Name of the property being accessed.

Returns
Cake\View\Helper|null

_configDelete() ¶ protected

_configDelete(string $key): void

Deletes a single config key.

Parameters
string $key

Key to delete.

Returns
void
Throws
Cake\Core\Exception\CakeException
if attempting to clobber existing config

_configRead() ¶ protected

_configRead(string|null $key): mixed

Reads a config key.

Parameters
string|null $key

Key to read.

Returns
mixed

_configWrite() ¶ protected

_configWrite(array<string, mixed>|string $key, mixed $value, string|bool $merge = false): void

Writes a config key.

Parameters
array<string, mixed>|string $key

Key to write to.

mixed $value

Value to write.

string|bool $merge optional

True to merge recursively, 'shallow' for simple merge, false to overwrite, defaults to false.

Returns
void
Throws
Cake\Core\Exception\CakeException
if attempting to clobber existing config

_confirm() ¶ protected

_confirm(string $okCode, string $cancelCode): string

Returns a string to be used as onclick handler for confirm dialogs.

Parameters
string $okCode

Code to be executed after user chose 'OK'

string $cancelCode

Code to be executed after user chose 'Cancel'

Returns
string

add() ¶ public

add(array|string $title, array|string|null $url = null, array<string, mixed> $options = []): $this

Add a crumb to the end of the trail.

Parameters
array|string $title

If provided as a string, it represents the title of the crumb. Alternatively, if you want to add multiple crumbs at once, you can provide an array, with each values being a single crumb. Arrays are expected to be of this form:

array|string|null $url optional

URL of the crumb. Either a string, an array of route params to pass to Url::build() or null / empty if the crumb does not have a link.

array<string, mixed> $options optional

Array of options. These options will be used as attributes HTML attribute the crumb will be rendered in (a

  • tag by default). It accepts two special keys:

  • Returns
    $this

    addClass() ¶ public

    addClass(array<string, mixed> $options, string $class, string $key = 'class'): array<string, mixed>

    Adds the given class to the element options

    Parameters
    array<string, mixed> $options

    Array options/attributes to add a class to

    string $class

    The class name being added.

    string $key optional

    the key to use for class. Defaults to 'class'.

    Returns
    array<string, mixed>

    configShallow() ¶ public

    configShallow(array<string, mixed>|string $key, mixed|null $value = null): $this

    Merge provided config with existing config. Unlike config() which does a recursive merge for nested keys, this method does a simple merge.

    Setting a specific value:

    $this->configShallow('key', $value);

    Setting a nested value:

    $this->configShallow('some.nested.key', $value);

    Updating multiple config settings at the same time:

    $this->configShallow(['one' => 'value', 'another' => 'value']);
    Parameters
    array<string, mixed>|string $key

    The key to set, or a complete array of configs.

    mixed|null $value optional

    The value to set.

    Returns
    $this

    findCrumb() ¶ protected

    findCrumb(string $title): int|null

    Search a crumb in the current stack which title matches the one provided as argument. If found, the index of the matching crumb will be returned.

    Parameters
    string $title

    Title to find.

    Returns
    int|null

    formatTemplate() ¶ public

    formatTemplate(string $name, array<string, mixed> $data): string

    Formats a template string with $data

    Parameters
    string $name

    The template name.

    array<string, mixed> $data

    The data to insert.

    Returns
    string

    getConfig() ¶ public

    getConfig(string|null $key = null, mixed $default = null): mixed

    Returns the config.

    Usage

    Reading the whole config:

    $this->getConfig();

    Reading a specific value:

    $this->getConfig('key');

    Reading a nested value:

    $this->getConfig('some.nested.key');

    Reading with default value:

    $this->getConfig('some-key', 'default-value');
    Parameters
    string|null $key optional

    The key to get or null for the whole config.

    mixed $default optional

    The return value when the key does not exist.

    Returns
    mixed

    getConfigOrFail() ¶ public

    getConfigOrFail(string $key): mixed

    Returns the config for this specific key.

    The config value for this key must exist, it can never be null.

    Parameters
    string $key

    The key to get.

    Returns
    mixed
    Throws
    InvalidArgumentException

    getCrumbs() ¶ public

    getCrumbs(): array

    Returns the crumb list.

    Returns
    array

    getTemplates() ¶ public

    getTemplates(string|null $template = null): array|string

    Gets templates to use or a specific template.

    Parameters
    string|null $template optional

    String for reading a specific template, null for all.

    Returns
    array|string

    getView() ¶ public

    getView(): Cake\View\View

    Get the view instance this helper is bound to.

    Returns
    Cake\View\View

    implementedEvents() ¶ public

    implementedEvents(): array<string, mixed>

    Get the View callbacks this helper is interested in.

    By defining one of the callback methods a helper is assumed to be interested in the related event.

    Override this method if you need to add non-conventional event listeners. Or if you want helpers to listen to non-standard events.

    Returns
    array<string, mixed>

    initialize() ¶ public

    initialize(array<string, mixed> $config): void

    Constructor hook method.

    Implement this method to avoid having to overwrite the constructor and call parent.

    Parameters
    array<string, mixed> $config

    The configuration settings provided to this helper.

    Returns
    void

    insertAfter() ¶ public

    insertAfter(string $matchingTitle, string $title, array|string|null $url = null, array<string, mixed> $options = []): $this

    Insert a crumb after the first matching crumb with the specified title.

    Finds the index of the first crumb that matches the provided class, and inserts the supplied callable before it.

    Parameters
    string $matchingTitle

    The title of the crumb you want to insert this one after.

    string $title

    Title of the crumb.

    array|string|null $url optional

    URL of the crumb. Either a string, an array of route params to pass to Url::build() or null / empty if the crumb does not have a link.

    array<string, mixed> $options optional

    Array of options. These options will be used as attributes HTML attribute the crumb will be rendered in (a

  • tag by default). It accepts two special keys:

  • Returns
    $this
    Throws
    LogicException
    In case the matching crumb can not be found.

    insertAt() ¶ public

    insertAt(int $index, string $title, array|string|null $url = null, array<string, mixed> $options = []): $this

    Insert a crumb at a specific index.

    If the index already exists, the new crumb will be inserted, before the existing element, shifting the existing element one index greater than before.

    If the index is out of bounds, an exception will be thrown.

    Parameters
    int $index

    The index to insert at.

    string $title

    Title of the crumb.

    array|string|null $url optional

    URL of the crumb. Either a string, an array of route params to pass to Url::build() or null / empty if the crumb does not have a link.

    array<string, mixed> $options optional

    Array of options. These options will be used as attributes HTML attribute the crumb will be rendered in (a

  • tag by default). It accepts two special keys:

  • Returns
    $this
    Throws
    LogicException
    In case the index is out of bound

    insertBefore() ¶ public

    insertBefore(string $matchingTitle, string $title, array|string|null $url = null, array<string, mixed> $options = []): $this

    Insert a crumb before the first matching crumb with the specified title.

    Finds the index of the first crumb that matches the provided class, and inserts the supplied callable before it.

    Parameters
    string $matchingTitle

    The title of the crumb you want to insert this one before.

    string $title

    Title of the crumb.

    array|string|null $url optional

    URL of the crumb. Either a string, an array of route params to pass to Url::build() or null / empty if the crumb does not have a link.

    array<string, mixed> $options optional

    Array of options. These options will be used as attributes HTML attribute the crumb will be rendered in (a

  • tag by default). It accepts two special keys:

  • Returns
    $this
    Throws
    LogicException
    In case the matching crumb can not be found

    prepend() ¶ public

    prepend(array|string $title, array|string|null $url = null, array<string, mixed> $options = []): $this

    Prepend a crumb to the start of the queue.

    Parameters
    array|string $title

    If provided as a string, it represents the title of the crumb. Alternatively, if you want to add multiple crumbs at once, you can provide an array, with each values being a single crumb. Arrays are expected to be of this form:

    array|string|null $url optional

    URL of the crumb. Either a string, an array of route params to pass to Url::build() or null / empty if the crumb does not have a link.

    array<string, mixed> $options optional

    Array of options. These options will be used as attributes HTML attribute the crumb will be rendered in (a

  • tag by default). It accepts two special keys:

  • Returns
    $this

    render() ¶ public

    render(array<string, mixed> $attributes = [], array<string, mixed> $separator = []): string

    Renders the breadcrumbs trail.

    Parameters
    array<string, mixed> $attributes optional

    Array of attributes applied to the wrapper template. Accepts the templateVars key to allow the insertion of custom template variable in the template.

    array<string, mixed> $separator optional

    Array of attributes for the separator template. Possible properties are :

    Returns
    string

    reset() ¶ public

    reset(): $this

    Removes all existing crumbs.

    Returns
    $this

    setConfig() ¶ public

    setConfig(array<string, mixed>|string $key, mixed|null $value = null, bool $merge = true): $this

    Sets the config.

    Usage

    Setting a specific value:

    $this->setConfig('key', $value);

    Setting a nested value:

    $this->setConfig('some.nested.key', $value);

    Updating multiple config settings at the same time:

    $this->setConfig(['one' => 'value', 'another' => 'value']);
    Parameters
    array<string, mixed>|string $key

    The key to set, or a complete array of configs.

    mixed|null $value optional

    The value to set.

    bool $merge optional

    Whether to recursively merge or overwrite existing config, defaults to true.

    Returns
    $this
    Throws
    Cake\Core\Exception\CakeException
    When trying to set a key that is invalid.

    setTemplates() ¶ public

    setTemplates(array<string, string> $templates): $this

    Sets templates to use.

    Parameters
    array<string, string> $templates

    Templates to be added.

    Returns
    $this

    templater() ¶ public

    templater(): Cake\View\StringTemplate

    Returns the templater instance.

    Returns
    Cake\View\StringTemplate

    Property Detail

    $Url ¶ public @property

    Type
    Cake\View\Helper\UrlHelper

    $_View ¶ protected

    The View instance this helper is attached to

    Type
    Cake\View\View

    $_config ¶ protected

    Runtime config

    Type
    array<string, mixed>

    $_configInitialized ¶ protected

    Whether the config property has already been configured with defaults

    Type
    bool

    $_defaultConfig ¶ protected

    Default config for the helper.

    Type
    array<string, mixed>

    $_templater ¶ protected

    StringTemplate instance.

    Type
    Cake\View\StringTemplate|null

    $crumbs ¶ protected

    The crumb list.

    Type
    array

    $helperInstances ¶ protected

    Loaded helper instances.

    Type
    array<string, \Cake\View\Helper>

    $helpers ¶ protected

    Other helpers used by BreadcrumbsHelper.

    Type
    array
    OpenHub
    Pingping
    Linode
    • Business Solutions
    • Showcase
    • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support

    Generated using CakePHP API Docs