/** * Get the current sfSympalMenuItem instance for this sympal context * * @return sfSympalMenuItem */ public function getCurrentMenuItem() { if (!$this->_currentMenuItem) { $this->_currentMenuItem = sfSympalMenuSiteManager::getInstance()->findCurrentMenuItem(); } return $this->_currentMenuItem; }
public static function getInstance() { if (!self::$_instance) { $className = sfConfig::get('app_sympal_config_menu_manager_class'); self::$_instance = new $className(); } return self::$_instance; }
/** * Get a menu split into 2 instances, a primary and submenu * * @param string $name The slug of the root menu item you wish to retrieve * @param string $showChildren Whether or not it should show the children when rendering * @param string $max The max menu items to include in the first menu * @param string $split Whether to return a 2nd menu item with the remaining menu items in it * @return mixed Either one sfSympalMenu instance of an array with 2 sfSympalMenu instances */ function get_sympal_split_menus($name, $showChildren = null, $max = null, $split = false) { $menu = sfSympalMenuSiteManager::getMenu($name, $showChildren); if ($menu) { return sfSympalMenuSiteManager::split($menu, $max, $split); } else { return false; } }
public function getMenu() { return sfSympalMenuSiteManager::getMenu($this['root_id']); }
$total = $primaryMenu->count(); $t->is($split['primary']->count(), 2, 'Test count() after splitting the menu into 2 pieces'); $t->is((string) $split['primary'], '<ul id="primary-menu"><li id="primary-blog" class="first">Blog</li><li id="primary-signout">Signout</li></ul>', 'Test split() primary'); $t->is((string) $split['secondary'], '<ul id="secondary-menu"><li id="primary-home">Home</li><li id="primary-sample-page">Sample Page</li><li id="primary-sample-content-list">Sample Content List</li><li id="primary-powered-by" class="last">Powered By</li></ul>', 'Test split() secondary'); $t->is($split['secondary']->count(), 4, 'Test secondary count()'); $footerMenu = $manager->getMenu('footer', false, 'sfSympalMenuSiteTest'); $t->is((string) $footerMenu, '', 'Test footer menu'); $table = Doctrine_Core::getTable('sfSympalMenuItem'); $menuItems = $table->createQuery('m')->execute(); $menuItem = $table->createQuery('m')->where('m.slug = ?', 'home')->fetchOne(); $t->is($menuItem->getIndentedName(), '- Home', 'Test sfSympalMenuItem::getIndentedName()'); $t->is((string) $menuItem, '- Home', 'Test sfSympalMenuItem::__toString()'); $t->is($menuItem->getContent()->getHeaderTitle(), 'Home', 'Test sfSympalMenuItem::getHeaderTitle()'); $t->is($menuItem->getLabel(), 'Home', 'Test sfSympalMenuItem::getLabel()'); $t->is($menuItem->getItemRoute(), '@sympal_content_home', 'Test sfSympalMenuItem::getItemRoute()'); $t->is($menuItem->getBreadcrumbs()->getPathAsString(), '', 'Test sfSympalBreadcrumbs::getPathAsString() returns nothing for home'); $menuItem = $table->createQuery('m')->where('m.slug = ?', 'sample-page')->fetchOne(); $t->is($menuItem->getBreadcrumbs()->getPathAsString(), 'Home / Sample Page', 'Test sfSympalBreadcrumbs::getPathAsString() returns nothing for home'); $menuManager = sfSympalMenuSiteManager::getInstance(); $menuManager->clear(); $profiler = new Doctrine_Connection_Profiler(); $conn = Doctrine_Manager::connection(); $conn->addListener($profiler); $menuManager->initialize(); $count = 0; foreach ($profiler as $event) { if ($event->getName() == 'execute') { $count++; } } $t->is($count, 1, 'Test menus do not require more than one query');
echo $contentType->getLabel(); ?> <?php echo __('Links'); ?> </h2> <ul> <?php if ($content->count()) { ?> <?php $menuItem = $content[0]->getMenuItem(); ?> <?php if ($menuItem && ($parentMenuNode = sfSympalMenuSiteManager::getMenu('primary')->findMenuItem($menuItem)->getParent())) { ?> <li> <?php echo image_tag('/sfSympalPlugin/images/folder.png'); ?> <?php echo link_to($parentMenuNode->getLabel(), $parentMenuNode->getRoute()); ?> </li> <?php } ?> <?php foreach ($content as $c) {
echo __('Links'); ?> </h2> <ul> <?php if ($content->count()) { ?> <?php $menuItem = $content[0]->getMenuItem(); ?> <?php $parentMenuNode = false; ?> <?php if ($menuItem && ($parentMenuNode = sfSympalMenuSiteManager::getMenu(sfSympalConfig::get('default_install_content_type_menu', null, 'primary'))->findMenuItem($menuItem)->getParent())) { ?> <li> <?php echo image_tag('/sfSympalPlugin/images/folder.png'); ?> <?php echo link_to($parentMenuNode->getLabel(), $parentMenuNode->getRoute()); ?> </li> <?php } ?> <?php foreach ($content as $c) {