Perforce Chronicle 2012.2/486814
API Documentation

Category_View_Helper_CategoryBreadcrumbs Class Reference

Specialized breadcrumb helper that takes a category and produces breadcrumbs for it. More...

List of all members.

Public Member Functions

 categoryBreadcrumbs ($category)
 Render breadcrumbs for the given category.

Detailed Description

Specialized breadcrumb helper that takes a category and produces breadcrumbs for it.

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

Category_View_Helper_CategoryBreadcrumbs::categoryBreadcrumbs ( category)

Render breadcrumbs for the given category.

Parameters:
Category_Model_Category$categorythe category to render breadcrumbs for.
Returns:
string rendered breadcrumbs for the given category.
    {
        // prepare breadcrumbs.
        $breadcrumbs = new Zend_Navigation(
            array(
                array(
                    'label'         => 'Categories',
                    'module'        => 'category',
                    'controller'    => 'index',
                    'action'        => 'index',
                    'active'        => true
                )
            )
        );

        // add category ancestry to breadcrumbs.
        if ($category instanceof Category_Model_Category) {
            $container = $breadcrumbs->current();
            $crumbs    = $category->getAncestors();
            $crumbs[]  = $category;
            foreach ($crumbs as $crumb) {
                $page = Zend_Navigation_Page::factory(
                    array(
                        'uri'           => $crumb->getUri(),
                        'label'         => $crumb->getTitle(),
                        'active'        => true,
                    )
                );

                // add page to parent container and advance container pointer.
                $container->addPage($page);
                $container = $page;
            }
        }
        return parent::breadcrumbs($breadcrumbs)->setSeparator('<span class="separator"><span>&gt;</span></span>');
    }

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