Note that there are some explanatory texts on larger screens.

plurals
  1. POcakePHP language routing
    primarykey
    data
    text
    <p>What I'm trying to achieve is that I can change only language prefix in the url, but getting problems... There is my routes:</p> <pre><code>$lang_regexp = implode('|', Configure::read('Config.languages')); Router::connect('/', array('controller' =&gt; 'languages', 'action' =&gt; 'choose')); Router::connect('/:lang/:controller/:action/*', array(), array('lang' =&gt; $lang_regexp)); // actual default page; can be any controller Router::connect('/:lang/pages/ajax_newsletter', array('controller' =&gt; 'pages', 'action' =&gt; 'ajax_newsletter')); Router::connect('/:lang/', array('controller' =&gt; 'pages', 'action' =&gt; 'index', 'home'), array('lang' =&gt; $lang_regexp)); Router::connect('/:lang/:slug', array('controller' =&gt; 'pages', 'action' =&gt; 'pages'), array('lang' =&gt; $lang_regexp)); Router::connect('/:slug', array('controller' =&gt; 'pages', 'action' =&gt; 'pages'), array('lang' =&gt; $lang_regexp)); Router::connect('/:lang/special_offers', array('controller' =&gt; 'pages', 'action' =&gt; 'offers')); Router::connect('/:lang/special_offers/*', array('controller' =&gt; 'pages', 'action' =&gt; 'offers_city')); Router::connect('/:lang/news/*', array('controller' =&gt; 'pages', 'action' =&gt; 'news_article')); Router::connect('/:lang/news', array('controller' =&gt; 'pages', 'action' =&gt; 'news')); Router::connect('/:lang/:slug/:id/*', array('controller' =&gt; 'pages', 'action' =&gt; 'offers'), array('lang' =&gt; $lang_regexp)); Router::connect('/cities/select', array('controller' =&gt; 'cities', 'action' =&gt; 'select')); Router::connect('/cities/select/*', array('controller' =&gt; 'cities', 'action' =&gt; 'select')); </code></pre> <p>my language switcher:</p> <pre><code>$this-&gt;html-&gt;link($this-&gt;html-&gt;image('flag_ru.gif', array("alt"=&gt;"", "width"=&gt;"14px", "height"=&gt;"12px", "title"=&gt;"")), array("lang" =&gt; "rus"), array('escape' =&gt; false)); </code></pre> <p><code>:lang/:slug</code> is menu entry so if I have menu like <code>localhost/eng/contact</code> after language change I get <code>localhost/rus/pages/pages</code>... How to change only language prefix?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload