示例#1
0
 public function testAddCrumb()
 {
     $this->assertEmpty($this->_block->toHtml());
     $info = array('label' => 'test label', 'title' => 'test title', 'link' => 'test link');
     $this->_block->addCrumb('test', $info);
     $html = $this->_block->toHtml();
     $this->assertContains('test label', $html);
     $this->assertContains('test title', $html);
     $this->assertContains('test link', $html);
 }
示例#2
0
 public function testGetCacheKeyInfo()
 {
     $crumbs = array('test' => array('label' => 'test label', 'title' => 'test title', 'link' => 'test link'));
     foreach ($crumbs as $crumbName => &$crumb) {
         $this->_block->addCrumb($crumbName, $crumb);
         $crumb += array('first' => null, 'last' => null, 'readonly' => null);
     }
     $cacheKeyInfo = $this->_block->getCacheKeyInfo();
     $crumbsFromCacheKey = unserialize(base64_decode($cacheKeyInfo['crumbs']));
     $this->assertEquals($crumbs, $crumbsFromCacheKey);
 }
 protected function _toHtml()
 {
     if ($this->getRequest()->getParam('cat', false)) {
         $cat_id = $this->getRequest()->getParam('cat', false);
         $category = Mage::getModel('catalog/category')->load($cat_id);
         $cat_name = $category->getName();
         $cat_url = $this->getBaseUrl() . $category->getUrlPath();
         $parents = Mage::getModel('catalog/category')->load($cat_id)->getParentCategories();
     }
     if (is_array($this->_crumbs)) {
         reset($this->_crumbs);
         $this->_crumbs[key($this->_crumbs)]['first'] = true;
         end($this->_crumbs);
         $this->_crumbs[key($this->_crumbs)]['last'] = true;
     }
     if ($cat_id) {
         if ($parents) {
             foreach ($parents as $p) {
                 $cat = Mage::getModel('catalog/category')->load($p->getId());
                 $this->_crumbs['category' . $cat->getId()] = array('label' => $cat->getName(), 'title' => $cat->getName(), 'link' => $cat->getUrlPath(), 'first' => '', 'last' => '', 'readonly' => '');
             }
         }
         $home = $this->_crumbs['home'];
         unset($this->_crumbs['home']);
         array_unshift($this->_crumbs, $home);
         //move search to the end
         $search = $this->_crumbs['search'];
         unset($this->_crumbs['search']);
         $this->_crumbs['search'] = $search;
     }
     $this->assign('crumbs', $this->_crumbs);
     return parent::_toHtml();
 }
示例#4
0
 function __construct()
 {
     parent::__construct();
     if (!$this->getBreadcrumbsSeparator()) {
         return;
     }
     $fullActionCode = Mage::helper('seo')->getFullActionCode();
     $allowedActions = array('cms_page_view', 'blog_index_list', 'blog_post_view', 'blog_cat_view');
     if (Mage::registry('current_category') || Mage::registry('current_product') || in_array($fullActionCode, $allowedActions)) {
         $this->_prepareBreadcrumbs();
         $this->setTemplate('seo/breadcrumbs.phtml');
     }
 }
示例#5
0
 protected function _toHtml()
 {
     $enabled = (bool) Mage::getStoreConfig('atwix_breadcrumbs/atwix_breadcrumbs/enabled');
     if (!$enabled) {
         return parent::_toHtml();
     }
     $this->prepareCrumbs();
     if (is_array($this->_crumbs)) {
         reset($this->_crumbs);
         $this->_crumbs[key($this->_crumbs)]['first'] = true;
         end($this->_crumbs);
         $this->_crumbs[key($this->_crumbs)]['last'] = true;
     }
     $this->assign('crumbs', $this->_crumbs);
     return parent::_toHtml();
 }
 protected function _beforeToHtml()
 {
     $replace = is_array($this->_crumbs) && isset($this->_crumbs['home']) && ($url = Mage::getStoreConfig(MVentory_Productivity_Model_Config::_CATEGORY_HOME_URL));
     if ($replace) {
         $shopUrl = $this->_crumbs['home']['link'];
         $this->_crumbs['home']['link'] = $url;
         $this->_crumbs['home']['first'] = null;
         $this->_crumbs['home']['last'] = null;
         $crumbs = array();
         foreach ($this->_crumbs as $name => $crumb) {
             $crumbs[$name] = $crumb;
             if ($name == 'home') {
                 $crumbs['shop'] = array('label' => $this->__('Products'), 'title' => null, 'link' => $shopUrl, 'first' => null, 'last' => null, 'readonly' => null);
             }
         }
         $this->_crumbs = $crumbs;
     }
     return parent::_beforeToHtml();
 }
示例#7
0
 protected function _toHtml()
 {
     if (is_array($this->_crumbs)) {
         reset($this->_crumbs);
         $this->_crumbs[key($this->_crumbs)]['first'] = true;
         end($this->_crumbs);
         $this->_crumbs[key($this->_crumbs)]['last'] = true;
     }
     if ($page = $this->getMenuBlock()->getCurrentPage()) {
         $path = $this->getMenuBlock()->getPathToPage($page->getId());
         /*
          * Page belongs to menu - display it
          */
         if (count($path)) {
             /* @var $helper Amasty_Menu_Helper_Data */
             $helper = Mage::helper('ammenu');
             $length = count($this->_crumbs);
             while ($length > 1) {
                 array_pop($this->_crumbs);
                 $length--;
             }
             $title = array();
             foreach ($path as $menuItem) {
                 $naming = $helper->getMenuItemName($menuItem);
                 $link = $helper->getMenuItemUrl($menuItem);
                 $crumb = array('label' => $naming, 'title' => $naming, 'link' => $link, 'last' => null);
                 if ($menuItem->cms_page_id === $page->getId()) {
                     $crumb['link'] = null;
                     $crumb['last'] = true;
                 }
                 $this->_crumbs[] = $crumb;
                 $title[] = $naming;
             }
             if ($headBlock = $this->getLayout()->getBlock('head')) {
                 $headBlock->setTitle(join($this->getTitleSeparator(), array_reverse($title)));
             }
         }
     }
     $this->assign('crumbs', $this->_crumbs);
     return parent::_toHtml();
 }
示例#8
0
 /**
  * Render block HTML
  *
  * @return string
  */
 protected function _toHtml()
 {
     $html = parent::_toHtml();
     $html = $this->_addMarkup($html);
     return $html;
 }
示例#9
0
 /**
  * Constructor
  */
 public function __construct()
 {
     parent::__construct();
     $this->setTemplate('magesty/crumbs/breadcrumbs.phtml');
 }
 public function __construct()
 {
     parent::__construct();
     $this->addCrumb('GOOGLE', ['label' => 'Doogle', 'title' => 'Woogle', 'link' => 'http://google.com']);
 }