/** * */ protected function _load() { $page = new Page(); $page->id = 0; $page_lang = new PageLang(); $page_lang->name = ''; $page_lang->url = ''; $page_lang->live_version = 0; $page->setRelation('pageCurrentLang', $page_lang); $this->pageLevels = [$page]; }
/** * @param array $options * @return string */ public function breadcrumb($options = []) { $defaultOptions = ['view' => 'default', '404-name' => '404']; $options = array_merge($defaultOptions, $options); $pageLevels = $this->pageLevels; if ($this->is404) { $page404 = new Page(); $pageLang = new PageLang(); $pageLang->url = ''; $pageLang->name = $options['404-name']; $page404->setRelation('pageCurrentLang', $pageLang); $pageLevels[] = $page404; } $crumbs = ''; if (!empty($pageLevels)) { $url = ''; end($pageLevels); $lowestLevel = key($pageLevels); foreach ($pageLevels as $level => $page) { if ($page && $page->pageLang()->url != '/') { $url .= '/' . $page->pageLang()->url; } $active = $lowestLevel == $level; $crumb = new BreadCrumb($page->pageLang(), $url, $active); if ($this->_viewExists('.breadcrumbs.' . $options['view'] . '.active_element') && $active) { $crumbs .= $this->_getRenderedView('breadcrumbs.' . $options['view'] . '.active_element', ['crumb' => $crumb]); } else { $crumbs .= $this->_getRenderedView('breadcrumbs.' . $options['view'] . '.link_element', ['crumb' => $crumb]); $crumbs .= $active ? $this->_getRenderedView('breadcrumbs.' . $options['view'] . '.separator') : ''; } } } return $this->_getRenderedView('breadcrumbs.' . $options['view'] . '.wrap', ['crumbs' => $crumbs]); }