cakephp 2.x router with i18n internationalization -


i'm using cakephp 2

i'm having hard time customize routes in routes.php.

so in case, have post model , postscontroller. index action lists post , each listed post clickable link goes show action. "standard" route posts>index is: "localhost/cakesite/posts/index" , translated version it's like: "localhost/cakesite/eng/posts/index". corresponding modified routes are: "localhost/cakesite/news" , "localhost/cakesite/eng/news".

now show action it's different because need pass parameters such slug , id, looks without modification of route: "localhost/cake/posts/show/75/language:eng". like: "localhost/cakesite/news/slug-id" , translated version: "localhost/cakesite/eng/news/slug-id". these both routes can't done. one: "localhost/cakesite/news/slug-id" working when have pointer on link get: "localhost/cake/posts/show/75" once click on it, redirects me on right url appears in browser like: "localhost/cake/news/slug-75". that's odd see on mouse-over have different result redirected url. when locale set on language, mouse-over: localhost/cake/posts/show/75/language:eng" , after clicked: "localhost/cake/news/slug-75", language disappear in redirected url.

so here routes far:

// news index router::connect('/news',     array('controller' => 'posts', 'action' => 'index')     ); router::connect('/:language/news',     array('controller' => 'posts', 'action' => 'index'),     array('language' => '[a-z]{3}','persist'=>array('language'))     );  // news show router::connect('/news/:slug-:id',     array('controller' => 'posts', 'action' => 'show'),     array('pass' => array('id', 'slug'),         'id' => '[0-9]+',         'slug' => '[a-z0-9\-]+')     ); router::connect('/:language/news/:slug-:id',     array('controller' => 'posts', 'action' => 'show'),     array('pass' => array('slug','id'), 'language' => '[a-z]{3}', 'slug' => '[a-z0-9\-]+', 'id' => '[0-9]+')     ); 

apphelper

class apphelper extends helper {      public function url($url = null, $full = false) {         if(!isset($url['language']) && isset($this->params['language'])) {             $url['language'] = $this->params['language'];         }         return parent::url($url, $full);     } } 

the actual link index show

$lang=configure::read('config.language');         echo $this->html->link(             $this->html->tag('h1', $v['name_'.$lang], array('class' => 'news_titre')).' '.             $this->html->tag('span', $v['created'], array('class' => 'news_date')).' '.             $this->html->tag('div', '', array('class' => 'clear_float')).' '.             $this->html->tag('span', $this->html->image("news/".$v['photo'], array( "alt" => $v['name_'.$lang])), array('class' => 'news_thumb')).' '.             $this->html->tag('p', $this->text->truncate(strip_tags($v['content_'.$lang]), 297, array('ellipsis' => '...', 'exact' => false)), array('class' => 'news_contenu')),             array('action' => 'show',$v['id']), array('class' => 'news_box', 'escape' => false)); 

i have put aboce codes show what's connected if need alse let me know edit post. so, have idea of i'm doing wrong?

thanks in advance help!

i think routes correct. bothering display of urls.

acording last bit of code, way you're ensambling url array like

$this->html->tag( /* etc */,                    /*here's redirection*/ array('action'=>'show', $id), /*etc*/) 

try changing array this

$this->html->tag( /* etc */,                    /*here's redirection*/ array('action'=>'show',                                                     'id' => $id,                                                    'slug' => $slug,                                                    'language' => $language), /*etc*/) 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -