API Documentation

Zend/View/Helper/Navigation/Menu.php

Show: inherited
Table of Contents

Zend Framework

LICENSE

This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.

Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_View  
Subpackage
Helper  
Version
$Id: Menu.php 24594 2012-01-05 21:27:01Z matthew $  

\Zend_View_Helper_Navigation_Menu

Package: Zend\View\Helper

Helper for rendering menus from navigation containers

Parent(s)
\Zend_View_Helper_Navigation_HelperAbstract < \Zend_View_Helper_HtmlElement < \Zend_View_Helper_Abstract
Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Properties

Propertyprotectedbool  $_onlyActiveBranch= 'false'

Whether only active branch should be rendered

Default valuefalseDetails
Type
bool
Propertyprotectedstring|array  $_partial= 'null'

Partial view script to use for rendering menu

Default valuenullDetails
Type
stringarray
Propertyprotectedbool  $_renderParents= 'true'

Whether parents should be rendered when only rendering active branch

Default valuetrueDetails
Type
bool
Propertyprotectedstring  $_ulClass= ''navigation''

CSS class to use for the ul element

Default value'navigation'Details
Type
string

Methods

methodprotected_normalizeOptions( array $options = array() ) : array

Normalizes given render options

Parameters
Name Type Description
$options array

[optional] options to normalize

Returns
Type Description
array normalized options
methodprotected_renderDeepestMenu( \Zend_Navigation_Container $container, string $ulClass, string $indent, int|null $minDepth, int|null $maxDepth ) : string

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

Parameters
Name Type Description
$container \Zend_Navigation_Container

container to render

$ulClass string

CSS class for first UL

$indent string

initial indentation

$minDepth int|null

minimum depth

$maxDepth int|null

maximum depth

Returns
Type Description
string rendered menu
methodprotected_renderMenu( \Zend_Navigation_Container $container, string $ulClass, string $indent, int|null $minDepth, int|null $maxDepth, bool $onlyActive ) : string

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

Parameters
Name Type Description
$container \Zend_Navigation_Container

container to render

$ulClass string

CSS class for first UL

$indent string

initial indentation

$minDepth int|null

minimum depth

$maxDepth int|null

maximum depth

$onlyActive bool

render only active branch?

Returns
Type Description
string
methodpublicgetOnlyActiveBranch( ) : bool

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.

Returns
Type Description
bool whether only active branch should be rendered
methodpublicgetPartial( ) : string|array|null

Returns partial view script to use for rendering menu

Returns
Type Description
string|array|null
methodpublicgetRenderParents( ) : bool

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

By default, this value is true.

Returns
Type Description
bool whether parents should be rendered
methodpublicgetUlClass( ) : string

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

Returns
Type Description
string CSS class
methodpublichtmlify( \Zend_Navigation_Page $page ) : string

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 Zend_View_Helper_Navigation_Abstract::htmlify()}.

Parameters
Name Type Description
$page \Zend_Navigation_Page

page to generate HTML for

Returns
Type Description
string HTML string for the given page
methodpublicmenu( \Zend_Navigation_Container $container = null ) : \Zend_View_Helper_Navigation_Menu

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

Parameters
Name Type Description
$container \Zend_Navigation_Container

[optional] container to operate on

Returns
Type Description
\Zend_View_Helper_Navigation_Menu fluent interface, returns self
methodpublicrender( \Zend_Navigation_Container $container = null ) : string

Renders menu

Implements {@link Zend_View_Helper_Navigation_Helper::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
Name Type Description
$container \Zend_Navigation_Container

[optional] container to render. Default is to render the container registered in the helper.

Returns
Type Description
string helper output
Details
See
\renderPartial()  
See
\renderMenu()  
methodpublicrenderMenu( \Zend_Navigation_Container $container = null, array $options = array() ) : string

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
Name Type Description
$container \Zend_Navigation_Container

[optional] container to create menu from. Default is to use the container retrieved from {@link getContainer()}.

$options array

[optional] options for controlling rendering

Returns
Type Description
string rendered menu
methodpublicrenderPartial( \Zend_Navigation_Container $container = null, string|array $partial = null ) : string

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.

echo 'Number of pages: ', count($this->container);

.

Parameters
Name Type Description
$container \Zend_Navigation_Container

[optional] container to pass to view script. Default is to use the container registered in the helper.

$partial 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.

Returns
Type Description
string helper output
methodpublicrenderSubMenu( \Zend_Navigation_Container $container = null, string $ulClass = null, string|int $indent = null ) : string

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:

renderMenu($container, array(
    'indent'           => $indent,
    'ulClass'          => $ulClass,
    'minDepth'         => null,
    'maxDepth'         => null,
    'onlyActiveBranch' => true,
    'renderParents'    => false
));
Parameters
Name Type Description
$container \Zend_Navigation_Container

[optional] container to render. Default is to render the container registered in the helper.

$ulClass string

[optional] CSS class to use for UL element. Default is to use the value from {@link getUlClass()}.

$indent string|int

[optional] indentation as a string or number of spaces. Default is to use the value retrieved from {@link getIndent()}.

Returns
Type Description
string rendered content
methodpublicsetOnlyActiveBranch( bool $flag = true ) : \Zend_View_Helper_Navigation_Menu

Sets a flag indicating whether only active branch should be rendered

Parameters
Name Type Description
$flag bool

[optional] render only active branch. Default is true.

Returns
Type Description
\Zend_View_Helper_Navigation_Menu fluent interface, returns self
methodpublicsetPartial( string|array $partial ) : \Zend_View_Helper_Navigation_Menu

Sets which partial view script to use for rendering menu

Parameters
Name Type Description
$partial 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.

Returns
Type Description
\Zend_View_Helper_Navigation_Menu fluent interface, returns self
methodpublicsetRenderParents( bool $flag = true ) : \Zend_View_Helper_Navigation_Menu

Enables/disables rendering of parents when only rendering active branch

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

Parameters
Name Type Description
$flag bool

[optional] render parents when rendering active branch. Default is true.

Returns
Type Description
\Zend_View_Helper_Navigation_Menu fluent interface, returns self
methodpublicsetUlClass( string $ulClass ) : \Zend_View_Helper_Navigation_Menu

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

Parameters
Name Type Description
$ulClass string

CSS class to set

Returns
Type Description
\Zend_View_Helper_Navigation_Menu fluent interface, returns self
Documentation was generated by DocBlox 0.15.1.