public function testContentType() { $params = array('url' => array(), 'controller' => 'nodes', 'action' => 'index', 'type' => 'blog'); $result = Router::reverse($params); $this->assertEquals('/nodes/index/type:blog', $result); CroogoRouter::contentType('blog'); $result = Router::reverse($params); $this->assertEquals('/blog', $result); CroogoRouter::contentType('page'); $params = array('url' => array(), 'controller' => 'nodes', 'action' => 'index', 'type' => 'page'); $result = Router::reverse($params); $this->assertEquals('/page', $result); }
<?php CroogoRouter::mapResources('Nodes.Nodes', array('prefix' => '/:api/:prefix/')); Router::connect('/:api/:prefix/nodes/lookup', array('plugin' => 'nodes', 'controller' => 'nodes', 'action' => 'lookup'), array('routeClass' => 'ApiRoute')); // Basic CroogoRouter::connect('/', array('plugin' => 'nodes', 'controller' => 'nodes', 'action' => 'promoted')); CroogoRouter::connect('/promoted/*', array('plugin' => 'nodes', 'controller' => 'nodes', 'action' => 'promoted')); CroogoRouter::connect('/search/*', array('plugin' => 'nodes', 'controller' => 'nodes', 'action' => 'search')); // Content types CroogoRouter::contentType('blog'); CroogoRouter::contentType('node'); if (Configure::read('Croogo.installed')) { CroogoRouter::routableContentTypes(); } // Page CroogoRouter::connect('/about', array('plugin' => 'nodes', 'controller' => 'nodes', 'action' => 'view', 'type' => 'page', 'slug' => 'about')); CroogoRouter::connect('/page/:slug', array('plugin' => 'nodes', 'controller' => 'nodes', 'action' => 'view', 'type' => 'page'));
/** * Apply routes for content types with routes enabled * * @return void */ public static function routableContentTypes() { try { $types = ClassRegistry::init('Taxonomy.Type')->find('all', array('cache' => array('name' => 'types', 'config' => 'croogo_types'))); foreach ($types as $type) { if (isset($type['Params']['routes']) && $type['Params']['routes']) { CroogoRouter::contentType($type['Type']['alias']); } } } catch (MissingConnectionException $e) { CakeLog::write('critical', __d('croogo', 'Unable to get routeable content types: %s', $e->getMessage())); } }
/** * test updateAllNodesPaths */ public function testUpdateAllNodesPaths() { $node = $this->Node->findById(1); $node['Node']['path'] = 'invalid one'; $this->assertTrue((bool) $this->Node->save($node)); CroogoRouter::contentType('blog'); $this->assertTrue($this->Node->updateAllNodesPaths()); $node = $this->Node->findById(1); $this->assertEquals('/blog/hello-world', $node['Node']['path']); }
<?php CroogoRouter::contentType('product'); CroogoRouter::connect('/panel', array('panel' => true, 'plugin' => 'webshop', 'controller' => 'customers', 'action' => 'dashboard'));