/** * onViewBeforeRender * * @param Event $event * * @return void */ public function onViewBeforeRender(Event $event) { $data = $event['data']; $data->user = $data->user ?: User::get(); $articleMapper = new ArticleMapper(); $data->articles = $data->articles ?: $articleMapper->find(['state' => 1], 'ordering'); foreach ($data->articles as $article) { $article->link = $article->url ?: Router::html('forum@article', ['id' => $article->id, 'alias' => $article->alias]); } // Template $config = Ioc::getConfig(); if ($config['natika.theme']) { $event['view']->getRenderer()->addPath(WINDWALKER_TEMPLATES . '/theme/' . $config['natika.theme'] . '/' . $event['view']->getName(), Priority::HIGH); } }
/** * getBreadcrumbs * * @param string $paths * * @return Data[] */ public static function getBreadcrumbs($paths) { if (!$paths) { return array(); } $paths = explode('/', $paths); $record = new CategoryRecord(); $breadcrumbs = array(); foreach (range(1, count($paths)) as $i) { $item = new Data(); $item->path = implode('/', $paths); $item->link = Router::html('forum:category', array('path' => $paths)); $record->load(array('path' => $item->path)); $item->title = $record->title; $breadcrumbs[] = $item; array_pop($paths); } $breadcrumbs[] = new Data(array('title' => 'Home', 'path' => '', 'link' => Router::html('forum:home'))); $breadcrumbs = array_reverse($breadcrumbs); return $breadcrumbs; }