php - cakePHP route element directs to missing controller action? -
i'm trying setup following routing in cakephp 2.3:
domain/news/slug
i've followed cookbook guidelines on routing , route gets created correct. problem run when selecting link 'missing method in newscontroller' error message.
here's i've configured:
router::connect( '/news/:slug/', array('controller' => 'news', 'action' => 'view'), array( 'pass' => array('slug'), 'slug' => '[^_]+' ) );
i'm passing in slug regular expression (any string not include underscore).
this link in index page:
<?php echo $this->html->link( $news['news']['title'], array( 'controller' => 'news', 'action' => 'view', 'slug' => $news['news']['slug'] ) ); ?>
as mentioned, url built correctly, , looks this: /news/test-slug-news-story
but when click on 'missing method in newscontroller' error message
is obvious i'm missing, cause i've looked @ long able see it.
thanks, paul
you can try one:
<?php // routing code router::connect('/news/:slug/', array( 'controller' => 'news', 'action' => 'view' ), array( 'slug' => '[a-za-z0-9_-]+' ) ); ?> <?php // html link code. echo $this->html->link( $news['news']['title'], array( 'controller' => 'news', 'action' => 'view', 'slug' => $news['news']['slug'] ) ); ?>
if not working please let me know :)
thanks
Comments
Post a Comment