Perforce Chronicle 2012.2/486814
API Documentation

Menu_View_Helper_Breadcrumbs Class Reference

Extends Zend's breadcrumbs helper to support passing a menu object or id. More...

List of all members.

Public Member Functions

 breadcrumbs ($container=null)
 This is the breadcrumbs helper entry point.
 htmlify (Zend_Navigation_Page $page)
 Extends the parent htmlify method to deal with the pages without a corresponding page to link to, e.g.

Detailed Description

Extends Zend's breadcrumbs helper to support passing a menu object or id.

Copyright:
2011-2012 Perforce Software. All rights reserved
License:
Please see LICENSE.txt in top-level folder of this distribution.
Version:
2012.2/486814

Member Function Documentation

Menu_View_Helper_Breadcrumbs::breadcrumbs ( container = null)

This is the breadcrumbs helper entry point.

It has been extended to add support for passing a menu object or id (string).

If the menu exists, it will be fetched; otherwise, an empty container will be used.

Parameters:
mixed$containeroptional - menu or container to operate on
Returns:
Menu_View_Helper_Breadcrumbs fluent interface, returns self
    {
        if ($container && !$container instanceof Zend_Navigation_Container) {
            if (!$container instanceof P4Cms_Menu && P4Cms_Menu::exists($container)) {
                $container = P4Cms_Menu::fetch($container);
            }
            if ($container instanceof P4Cms_Menu) {
                // tag the page cache so it can be appropriately cleared later
                if (P4Cms_Cache::canCache('page')) {
                    P4Cms_Cache::getCache('page')
                        ->addTag('p4cms_menu')
                        ->addTag('p4cms_menu_' . bin2hex($container->getId()));
                }

                $container = $container->getExpandedContainer();
            } else {
                $container = new Zend_Navigation;
            }
        }
        
        if (null !== $container) {
            $this->setContainer($container);
        }

        return $this;
    }
Menu_View_Helper_Breadcrumbs::htmlify ( Zend_Navigation_Page $  page)

Extends the parent htmlify method to deal with the pages without a corresponding page to link to, e.g.

heading menu items.

Parameters:
Zend_Navigation_Page$pagepage to generate HTML for
Returns:
string HTML string for the given page
    {
        // if there is a url, use the parent's htmlify method
        if ($page->getHref()) {
            return parent::htmlify($page);
        }

        // if there is NO url defined, don't add the <a> tag.
        // get label for translating
        $label = $page->getLabel();

        if ($this->getUseTranslator() && $t = $this->getTranslator()) {
            if (is_string($label) && !empty($label)) {
                $label = $t->translate($label);
            }
        }

        return $this->view->escape($label);
    }

The documentation for this class was generated from the following file: