1254. Class

1254.1. Zend\View\Helper\Navigation\Menu

Helper for rendering menus from navigation containers

1254.1.1. Methods

1254.1.1.1. __invoke

__invoke()

View helper entry point: Retrieves helper and optionally sets container to operate on

Parameters:AbstractContainer – [optional] container to operate on
Return type:Menu fluent interface, returns self

1254.1.1.2. setUlClass

setUlClass()

Sets CSS class to use for the first ‘ul’ element when rendering

Parameters:string – CSS class to set
Return type:Menu fluent interface, returns self

1254.1.1.3. getUlClass

getUlClass()

Returns CSS class to use for the first ‘ul’ element when rendering

Return type:string CSS class

1254.1.1.4. setOnlyActiveBranch

setOnlyActiveBranch()

Sets a flag indicating whether only active branch should be rendered

Parameters:bool – [optional] render only active branch. Default is true.
Return type:Menu fluent interface, returns self

1254.1.1.5. getOnlyActiveBranch

getOnlyActiveBranch()

Returns a flag indicating whether only active branch should be rendered

By default, this value is false, meaning the entire menu will be be rendered.

Return type:bool whether only active branch should be rendered

1254.1.1.6. escapeLabels

escapeLabels()

Sets a flag indicating whether labels should be escaped

Parameters:bool – [optional] escape labels. Default is true.
Return type:Menu fluent interface, returns self

1254.1.1.7. setRenderParents

setRenderParents()

Enables/disables rendering of parents when only rendering active branch

See {@link setOnlyActiveBranch()} for more information.

Parameters:bool – [optional] render parents when rendering active branch. Default is true.
Return type:Menu fluent interface, returns self

1254.1.1.8. getRenderParents

getRenderParents()

Returns flag indicating whether parents should be rendered when rendering only the active branch

By default, this value is true.

Return type:bool whether parents should be rendered

1254.1.1.9. setPartial

setPartial()

Sets which partial view script to use for rendering menu

Parameters:string|array – partial view script or null. If an array is given, it is expected to contain two values; the partial view script to use, and the module where the script can be found.
Return type:Menu fluent interface, returns self

1254.1.1.10. getPartial

getPartial()

Returns partial view script to use for rendering menu

Return type:string|array|null

1254.1.1.11. htmlify

htmlify()

Returns an HTML string containing an ‘a’ element for the given page if the page’s href is not empty, and a ‘span’ element if it is empty

Overrides {@link AbstractHelper::htmlify()}.

Parameters:
  • AbstractPage – page to generate HTML for
  • bool – Whether or not to escape the label
Return type:

string HTML string for the given page

1254.1.1.12. normalizeOptions

normalizeOptions()

Normalizes given render options

Parameters:array – [optional] options to normalize
Return type:array normalized options

1254.1.1.13. renderDeepestMenu

renderDeepestMenu()

Renders the deepest active menu within [$minDepth, $maxDepth], (called from {@link renderMenu()})

Parameters:
  • AbstractContainer – container to render
  • string – CSS class for first UL
  • string – initial indentation
  • int|null – minimum depth
  • int|null – maximum depth
  • bool – Whether or not to escape the labels
Return type:

string rendered menu

1254.1.1.14. renderNormalMenu

renderNormalMenu()

Renders a normal menu (called from {@link renderMenu()})

Parameters:
  • AbstractContainer – container to render
  • string – CSS class for first UL
  • string – initial indentation
  • int|null – minimum depth
  • int|null – maximum depth
  • bool – render only active branch?
  • bool – Whether or not to escape the labels
Return type:

string

1254.1.1.15. renderMenu

renderMenu()

Renders helper

Renders a HTML ‘ul’ for the given $container. If $container is not given, the container registered in the helper will be used.

Available $options:

Parameters:
  • AbstractContainer – [optional] container to create menu from. Default is to use the container retrieved from {@link getContainer()}.
  • array – [optional] options for controlling rendering
Return type:

string rendered menu

1254.1.1.16. renderSubMenu

renderSubMenu()

Renders the inner-most sub menu for the active page in the $container

This is a convenience method which is equivalent to the following call: <code> renderMenu($container, array(

‘indent’ => $indent, ‘ulClass’ => $ulClass, ‘minDepth’ => null, ‘maxDepth’ => null, ‘onlyActiveBranch’ => true, ‘renderParents’ => false

)); </code>

Parameters:
  • AbstractContainer – [optional] container to render. Default is to render the container registered in the helper.
  • string – [optional] CSS class to use for UL element. Default is to use the value from {@link getUlClass()}.
  • string|int – [optional] indentation as a string or number of spaces. Default is to use the value retrieved from {@link getIndent()}.
Return type:

string rendered content

1254.1.1.17. renderPartial

renderPartial()

Renders the given $container by invoking the partial view helper

The container will simply be passed on as a model to the view script as-is, and will be available in the partial script as ‘container’, e.g. <code>echo ‘Number of pages: ‘, count($this->container);</code>.

Parameters:
  • AbstractContainer – [optional] container to pass to view script. Default is to use the container registered in the helper.
  • string|array – [optional] partial view script to use. Default is to use the partial registered in the helper. If an array is given, it is expected to contain two values; the partial view script to use, and the module where the script can be found.
Return type:

string helper output

Throws :

ExceptionRuntimeException if no partial provided

Throws :

ExceptionInvalidArgumentException if partial is invalid array

1254.1.1.18. render

render()

Renders menu

Implements {@link HelperInterface::render()}.

If a partial view is registered in the helper, the menu will be rendered using the given partial script. If no partial is registered, the menu will be rendered as an ‘ul’ element by the helper’s internal method.

Parameters:AbstractContainer – [optional] container to render. Default is to render the container registered in the helper.
Return type:string helper output