View/Helper/Navigation/Menu.php

Show: PublicProtectedPrivateinherited
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 [email protected] so we can send you a copy immediately.
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_View  
Subpackage
Helper  
Version
$Id$  

\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-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Properties

>VPropertyprotectedstring $_activeClass = 'active'
CSS class to use for the active elements
Default value'active'Details
Type
string
>VPropertyprotectedbool $_addPageClassToLi = false
Adds CSS class from page to li element
Default valuefalseDetails
Type
bool
>VPropertyprotectedbool $_expandSiblingNodesOfActiveBranch = false
Expand all sibling nodes of active branch nodes
Default valuefalseDetails
Type
bool
>VPropertyprotectedstring $_innerIndent = ' '
Inner indentation string
Default value' 'Details
Type
string
>VPropertyprotectedbool $_onlyActiveBranch = false
Whether only active branch should be rendered
Default valuefalseDetails
Type
bool
>VPropertyprotectedstring $_parentClass = 'menu-parent'
CSS class to use for the parent li element
Default value'menu-parent'Details
Type
string
>VPropertyprotectedstring|array $_partial = null
Partial view script to use for rendering menu
Default valuenullDetails
Type
string | array
>VPropertyprotectedbool $_renderParentClass = false
Whether parent li elements should be rendered with parent class
Default valuefalseDetails
Type
bool
>VPropertyprotectedbool $_renderParents = true
Whether parents should be rendered when only rendering active branch
Default valuetrueDetails
Type
bool
>VPropertyprotectedstring $_ulClass = 'navigation'
CSS class to use for the ul element
Default value'navigation'Details
Type
string
>VPropertyprotectedstring $_ulId = null
Unique identifier (id) for the ul element
Default valuenullDetails
Type
string

Methods

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

Normalizes given render options

Parameters
NameTypeDescription
$optionsarray

[optional] options to normalize

Returns
TypeDescription
arraynormalized options
methodprotected_renderDeepestMenu(\Zend_Navigation_Container $container, string $ulClass, string $indent, string $innerIndent, int | null $minDepth, int | null $maxDepth, string | null $ulId, bool $addPageClassToLi, string | null $activeClass, string $parentClass, bool $renderParentClass) : string

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

Parameters
NameTypeDescription
$container\Zend_Navigation_Container

container to render

$ulClassstring

CSS class for first UL

$indentstring

initial indentation

$innerIndentstring

inner indentation

$minDepthint | null

minimum depth

$maxDepthint | null

maximum depth

$ulIdstring | null

unique identifier (id)

                                             for first UL
$addPageClassToLibool

adds CSS class from page to li element

$activeClassstring | null

CSS class for active element

$parentClassstring

CSS class for parent

                                                 li's
$renderParentClassbool

Render parent class?

Returns
TypeDescription
stringrendered menu (HTML)
methodprotected_renderMenu(\Zend_Navigation_Container $container, string $ulClass, string $indent, string $innerIndent, int | null $minDepth, int | null $maxDepth, bool $onlyActive, bool $expandSibs, string | null $ulId, bool $addPageClassToLi, string | null $activeClass, string $parentClass, bool $renderParentClass) : string

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

Parameters
NameTypeDescription
$container\Zend_Navigation_Container

container to render

$ulClassstring

CSS class for first UL

$indentstring

initial indentation

$innerIndentstring

inner indentation

$minDepthint | null

minimum depth

$maxDepthint | null

maximum depth

$onlyActivebool

render only active branch?

$expandSibsbool

render siblings of active

                                             branch nodes?
$ulIdstring | null

unique identifier (id)

                                             for first UL
$addPageClassToLibool

adds CSS class from page to li element

$activeClassstring | null

CSS class for active element

$parentClassstring

CSS class for parent

                                                 li's
$renderParentClassbool

Render parent class?

Returns
TypeDescription
stringrendered menu (HTML)
methodpublicaddPageClassToLi(bool $flag = true) : \Zend_View_Helper_Navigation_Menu

Adds CSS class from page to li element

Before:
  • Bar
  • After:
  • Bar
  • Parameters
    NameTypeDescription
    $flagbool

    [optional] adds CSS class from

                                         page to li element
    Returns
    TypeDescription
    \Zend_View_Helper_Navigation_Menufluent interface, returns self
    methodpublicgetActiveClass() : string

    Returns CSS class to use for the active elements when rendering

    Returns
    TypeDescription
    stringCSS class
    methodpublicgetAddPageClassToLi() : bool

    Returns a flag indicating whether the CSS class from page to be added to li element

    Returns
    TypeDescription
    bool
    methodpublicgetExpandSiblingNodesOfActiveBranch() : bool

    Returns a flag indicating whether to expand all sibling nodes of the active branch

    By default, this value is false, meaning the entire menu will be be rendered.
    Returns
    TypeDescription
    boolwhether siblings of nodes in the active branch should be expanded
    methodpublicgetInnerIndent() : string

    Returns inner indentation (format output is respected)

    Returns
    TypeDescription
    stringindentation string or an empty string
    Details
    See
     
    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
    TypeDescription
    boolwhether only active branch should be rendered
    methodpublicgetParentClass() : string

    Returns CSS class to use for the parent lie elements when rendering

    Returns
    TypeDescription
    stringCSS class
    methodpublicgetPartial() : string | array | null

    Returns partial view script to use for rendering menu

    Returns
    TypeDescription
    string | array | null
    methodpublicgetRenderParentClass() : bool

    Returns flag indicating whether parent class should be rendered to the li element

    Returns
    TypeDescription
    boolwhether parent class should be rendered
    methodpublicgetRenderParents() : bool

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

    By default, this value is true.
    Returns
    TypeDescription
    boolwhether parents should be rendered
    methodpublicgetUlClass() : string

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

    Returns
    TypeDescription
    stringCSS class
    methodpublicgetUlId() : string | null

    Returns unique identifier (id) to use for the first 'ul' element when rendering

    Returns
    TypeDescription
    string | nullUnique identifier (id); Default is 'null'
    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
    NameTypeDescription
    $page\Zend_Navigation_Page

    page to generate HTML for

    Returns
    TypeDescription
    stringHTML 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
    NameTypeDescription
    $container\Zend_Navigation_Container

    [optional] container to

                                              operate on
    Returns
    TypeDescription
    \Zend_View_Helper_Navigation_Menufluent 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
    NameTypeDescription
    $container\Zend_Navigation_Container

    [optional] container to

                                              render. Default is to
                                              render the container
                                              registered in the helper.
    Returns
    TypeDescription
    stringhelper output
    Details
    See
     
    See
     
    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
    NameTypeDescription
    $container\Zend_Navigation_Container

    [optional] container to

                                              create menu from. Default
                                              is to use the container
                                              retrieved from
                                              {@link getContainer()}.
    $optionsarray

    [optional] options for

                                              controlling rendering
    Returns
    TypeDescription
    stringrendered 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
    NameTypeDescription
    $container\Zend_Navigation_Container

    [optional] container to

                                              pass to view script. Default
                                              is to use the container
                                              registered in the helper.
    $partialstring | 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
    TypeDescription
    stringhelper output
    Throws
    ExceptionDescription
    \Zend_View_ExceptionWhen no partial script is set
    methodpublicrenderSubMenu(\Zend_Navigation_Container $container = null, string | null $ulClass = null, string | int $indent = null, string | null $ulId = null, bool $addPageClassToLi = false, string | int $innerIndent = 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
    NameTypeDescription
    $container\Zend_Navigation_Container

    [optional] container to

                                              render. Default is to render
                                              the container registered in
                                              the helper.
    $ulClassstring | null

    [optional] CSS class to

                                              use for UL element. Default
                                              is to use the value from
                                              {@link getUlClass()}.
    $indentstring | int

    [optional] indentation as

                                              a string or number of
                                              spaces. Default is to use
                                              the value retrieved from
                                              {@link getIndent()}.
    $ulIdstring | null

    [optional] Unique identifier

                                              (id) use for UL element
    $addPageClassToLibool

    adds CSS class from page to li element

    $innerIndentstring | int

    [optional] inner

                                                 indentation as a string
                                                 or number of spaces.
                                                 Default is to use the
                                                 {@link getInnerIndent()}.
    Returns
    TypeDescription
    stringrendered content
    methodpublicsetActiveClass(string $activeClass) : \Zend_View_Helper_Navigation_Menu

    Sets CSS class to use for the active elements when rendering

    Parameters
    NameTypeDescription
    $activeClassstring

    CSS class to set

    Returns
    TypeDescription
    \Zend_View_Helper_Navigation_Menufluent interface, returns self
    methodpublicsetExpandSiblingNodesOfActiveBranch(bool $flag = true) : \Zend_View_Helper_Navigation_Menu

    Sets a flag indicating whether to expand all sibling nodes of the active branch

    Parameters
    NameTypeDescription
    $flagbool

    [optional] expand all siblings of

                                          nodes in the active branch. Default is true.
    Returns
    TypeDescription
    \Zend_View_Helper_Navigation_Menufluent interface, returns self
    methodpublicsetInnerIndent(string | int $indent) : \Zend_View_Helper_Navigation_HelperAbstract

    Set the inner indentation string for using in {@link render()}, optionally a number of spaces to indent with

    Parameters
    NameTypeDescription
    $indentstring | int

    indentation string or number of spaces

    Returns
    TypeDescription
    \Zend_View_Helper_Navigation_HelperAbstractfluent interface, returns self
    methodpublicsetOnlyActiveBranch(bool $flag = true) : \Zend_View_Helper_Navigation_Menu

    Sets a flag indicating whether only active branch should be rendered

    Parameters
    NameTypeDescription
    $flagbool

    [optional] render only active

                                          branch. Default is true.
    Returns
    TypeDescription
    \Zend_View_Helper_Navigation_Menufluent interface, returns self
    methodpublicsetParentClass(string $parentClass) : \Zend_View_Helper_Navigation_Menu

    Sets CSS class to use for the parent li elements when rendering

    Parameters
    NameTypeDescription
    $parentClassstring

    CSS class to set to parents

    Returns
    TypeDescription
    \Zend_View_Helper_Navigation_Menufluent interface, returns self
    methodpublicsetPartial(string | array $partial) : \Zend_View_Helper_Navigation_Menu

    Sets which partial view script to use for rendering menu

    Parameters
    NameTypeDescription
    $partialstring | 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
    TypeDescription
    \Zend_View_Helper_Navigation_Menufluent interface, returns self
    methodpublicsetRenderParentClass(bool $flag = true) : \Zend_View_Helper_Navigation_Menu

    Enables/disables rendering of parent class to the li element

    Parameters
    NameTypeDescription
    $flagbool

    [optional] render with parent

                                         class. Default is true.
    Returns
    TypeDescription
    \Zend_View_Helper_Navigation_Menufluent 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
    NameTypeDescription
    $flagbool

    [optional] render parents when

                                          rendering active branch.
                                          Default is true.
    Returns
    TypeDescription
    \Zend_View_Helper_Navigation_Menufluent interface, returns self
    methodpublicsetUlClass(string $ulClass) : \Zend_View_Helper_Navigation_Menu

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

    Parameters
    NameTypeDescription
    $ulClassstring

    CSS class to set

    Returns
    TypeDescription
    \Zend_View_Helper_Navigation_Menufluent interface, returns self
    methodpublicsetUlId(string | null $ulId) : \Zend_View_Helper_Navigation_Menu

    Sets unique identifier (id) to use for the first 'ul' element when rendering

    Parameters
    NameTypeDescription
    $ulIdstring | null

    Unique identifier (id) to set

    Returns
    TypeDescription
    \Zend_View_Helper_Navigation_Menufluent interface, returns self
    Documentation was generated by phpDocumentor 2.2.0 .