/** * Renders a group of navigations defined as Configurations. * * A Configuration with a type ´navigation´ must follow this naming conventions: * nav.{name of navigation group}.{name of navigation} * e.g. nav.sidebar.main, nav.sidebar.mailplugin, ... * * $this->Navigation->group('sidebar') will render all Configurations with a slug starting with * ´nav.sidebar.´ that are of type `navigation`. In addition it renders all navigations based * on files from all loaded libraries, that have files at {:library}/data/nav/{:name}.foo.neon * * @param string $name part of a navigation slug * @param array $options additional options: * - `pattern`: pattern of slug to search configurations of, defaults to `nav.{:name}.` * - `seperator`: glue-character to implode all navigations together with * - `db`: set to false to avoid database-based rendering of navigations (configurations) * - `files`: set to false to avoid file-based rendering of navigations * @return string all navigations */ public function group($name, array $options = array()) { $defaults = array('pattern' => 'nav.{:name}.', 'seperator' => "\n", 'files' => true, 'db' => true); $options += $defaults; $search = String::insert($options['pattern'], compact('name')); $result = array(); if ($options['db']) { $configs = Configurations::search($search); if ($configs) { foreach ($configs as $nav) { $result[] = $this->render($nav); } } } if (!$options['files']) { return implode($options['seperator'], $result); } $conditions = array('slug' => $name); $files = Neon::find(array('source' => 'nav', 'key' => 'slug'), 'all', compact('conditions')); if ($files) { foreach ($files as $file => $nav) { $caption = Inflector::humanize(str_replace(sprintf('%s.', $name), '', $file)); $result[] = $this->render($nav, compact('caption')); } } return implode($options['seperator'], $result); }