renathy
(Renate Vidruska)
1
Hi!
Currently I have the following Url rewriting scheme:
'<view:(home|about|offer|toknow|delivery|contacts)>' => '/site/page', // /site/page?view=about -> /about
Above code is for static pages.
However, I want another thing, because my website is in another language. And I need to change every static page name to local name.
For example, I want "contacts" to be "kontakti".
So, I want www.example.com/kontakti to work the same as www.example.com/contacts works now.
_uJJwAL
(_uJJwAL_)
2
If possible, explicitly define url rules for each of the translation.
seenivasan
(Chellamnivas)
3
Dear Renathy
Kindly check whether the following is helpful.
Create a bahavior and put inside the components folder.
components/applicationBehavior.php
<?php
class applicationBehavior extends CBehavior
{ private $_owner;
public function events()
{
return array(
'onBeginRequest'=>'addRule',
);
}
public function addRule()
{
$owner=$this->_owner=$this->getOwner();
if($owner->language=='en_us')
{
$owner->urlManager->addRules(array(
'<view:(home|about|offer|toknow|delivery|contacts)>' => '/site/page',
));
}
if($owner->language=='it')
{
$owner->urlManager->addRules(array(
'<view:(home|about|offer|toknow|delivery|kontakti)>' => '/site/page',
));
}
}
}
Attach this behavior as a property to main configuration file.
main.php
..................................................
'behaviors'=>array(
'class'=>'application.components.applicationBehavior',
),
.....................................................
Regards.
yugenekr
(Yugenekr)
4
This wiki article may be useful.