From: Brad B. <bbu...@uc...> - 2013-04-24 19:19:03
|
I'm still having a problem with this. I've tried both approaches and they render the same result. I currently have: namespace VuFindLocal\Module\Configuration; $config = array( 'router' => array( 'routes' => array( 'alphabrowse-home' => array( 'type' => 'Zend\Mvc\Router\Http\Literal', 'options' => array( 'route' => '/alphabrowse/home', 'defaults' => array( 'controller' => 'Alphabrowse', 'action' => 'Home', ) ) ), 'alphabrowse-results' => array( 'type' => 'Zend\Mvc\Router\Http\Literal', 'options' => array( 'route' => '/alphabrowse/results', 'defaults' => array( 'controller' => 'Alphabrowse', 'action' => 'Results', ) ) ), ), ), 'controllers' => array( 'invokables' => array( 'alphabrowse\home' => 'VuFindLocal\Controller\AlphabrowseController', 'alphabrowse\results' => 'VuFindLocal\Controller\AlphabrowseController', ), ), ); /*$staticRoutes = array( 'Alphabrowse/Home', 'Alphabrowse/Results', ); // Build static routes foreach ($staticRoutes as $route) { list($controller, $action) = explode('/', $route); $routeName = str_replace('/', '-', strtolower($route)); $config['router']['routes'][$routeName] = array( 'type' => 'Zend\Mvc\Router\Http\Literal', 'options' => array( 'route' => '/' . $route, 'defaults' => array( 'controller' => $controller, 'action' => $action, ) ) ); }*/ return $config; It doesn't matter if I use the hand generated routs or the staticRouts array, I still get, " *error-controller-cannot-dispatch*". Interestingly, the alphabrowse-home routing works fine and if I change the action to 'Home' in the alphabrowse-results defaults, it will render to the Home template fine. It's only the alphabrowse-results routing that does not work. It's almost like it's not recognizing the resultsAction in the AlphabrowseController. It makes me think that it's still using the controller from the VuFind namespace and not the one in my local module. Does anybody know what I'm missing here? On 4/23/13 2:03 PM, Demian Katz wrote: > > The problem is that the $staticRoutes variable from your local > module.config.php is not doing anything. The $staticRoutes variable > in the main configuration is a convenience variable used to > dynamically generate some route settings. You'll have to copy and > paste the main VuFind module's $staticRoutes processing routine into > your local module if you want to do similar things there (or you could > just hand-generate the routes and paste those into the main $config > array -- whatever is easier for you). > > - Demian > > *From:*Brad Busenius [mailto:bbu...@uc...] > *Sent:* Tuesday, April 23, 2013 2:57 PM > *To:* vuf...@li... > *Subject:* [VuFind-Tech] routing problem > > I'm trying to setup a separate view for alphabrowse results. When I > edit the all of the files in the VuFind namespace everything works > fine, however, when I try to set it up as a module it fails. I have > the following things in place: > * > 1. local module.config.php * > > namespace VuFindLocal\Module\Configuration; > > $config = array( > 'controllers' => array( > 'invokables' => array( > 'alphabrowse' => > 'VuFindLocal\Controller\AlphabrowseController', > ), > ), > ); > > $staticRoutes = array( > 'Alphabrowse/Home', 'Alphabrowse/Results', > ); > > return $config; > > *2. Local module Alphabrowse controller * > > namespace VuFindLocal\Controller; > use VuFind\Connection\Manager as ConnectionManager, > VuFind\Exception\Solr as SolrException; > > class alphabrowsecontroller extends \VuFind\Controller\AbstractBase > { > ... > public function homeAction() > { > ... > public function resultsAction() > { > ... > > *3. Two templates in the alphabrowse folder * > > home.phtml, results.phtml > > The current error I'm getting is " > Zend\View\Renderer\PhpRenderer::render: Unable to render template > "alphabrowsecontroller/results"; resolver could not resolve to a > file". Anyhow, I can't for the life of me figure out what I'm doing > wrong here. Does anybody have any ideas? > > Brad > |