I am not able to get the yii parameterized hostnames working. I am trying to display http://member.testsite.com when the user clicks on login from http://www.testsite.com.
I have the member module created with SiteController.
In my rules, I have:
'rules' => array(
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'http://member.testsite.com' => 'member/site/index',
),
In my login, I have the URL pointing to
'url'=>array('member/site/index')
When I hover over login, it shows member.testsite.com, but when I click it takes me to website-unavailable.com
When I change the rules to
'http://member.testsite.com' => 'member/<controller>/<action>',
it takes me to testsite.com/member/site/index/
Am I missing any step?
Example:
'rules' => array(
'://<member:\w+>.<host>/<controller:\w+>/<action:\w+>'
=> '<controller>/<action>',
),
Related
I'm trying to map services/v2/ to servicesV2.
I tried:
'services/v2' => 'servicesV2',
And I tried:
'services/v2/' => 'servicesV2/',
And:
'services/v2/<action:\w+>' => 'servicesV2/<action:\w+>',
And I got an error:
The system is unable to find the requested action "v2".
Did you put it on the begin of the array?
'rules' => array(
'services/v2' => 'servicesV2',
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
),
In my web application, I want to implement a date field. For this i am using CJuiDatePicker. But for me it not showing calendar.
My code is,
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'name' => 'Employee[employee_joiningdate]',
'id' => 'Employee_employee_joiningdate',
'value' => Yii::app()->dateFormatter->format("d-M-y", strtotime($model->employee_joiningdate)),
'options' => array(`
'showAnim' => 'slide', //'slide','fold','slideDown','fadeIn','blind','bounce','clip','drop'
'showOtherMonths' => true, // Show Other month in jquery
'selectOtherMonths' => true, // Select Other month in jquery
),
'htmlOptions' => array(
'class' => 'form-control'
),
));`
What i am doing wrong?
Please help me....
Thanks in advance.
So using yii I want to have urls like this:
mydomain.com/some-short-slug
And this url to map the following:
mydomain.com/book?bookslug=some-short-slug
How can I do this?
You need do this inside url-manager:
'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => false,
'caseSensitive' => false,
'rules' => array(
...
'<slug>'=>'book/index'
...
),
Now, if url like mydomain.com/some-short-slug, you have $slug equal to "some-short-slug" in the actionIndex of BookController
currently when using history.js in my view my url looks like this
http://localhost/dev/clubs/
when i sort OR go to the next page it adds the modulesName, Clubs and relationTable to the url
http://localhost/dev/modulesName/clubs/index/?Clubs_sort=relationTable.Make.desc&page=2
how would i make it look nicer? Say something like this maybe (without the /index/ too)
http://localhost/dev/clubs/?sort=Make.desc&page=2
currently in my modules controller i have this
public function actionIndex()
{
$dataProvider=new CActiveDataProvider('Clubs', array(
'criteria' => array(
'with' =>'Make',
),
'sort'=>array(
'defaultOrder'=>'Make.Make ASC',
'attributes'=>array(
'Make.Make'=>array(
'asc'=>'Make.Make',
'desc'=>'Make.Make DESC',
)
)
),
//for friendly url when history,js is enabled
'pagination'=>array(
'pageVar'=>'page'
)
));
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
}
and in my url manager i have this
'<action:(clubs|finance)>' => 'modulesName/<action>',
any idea how to fix this? Thanks
You can use the url manager to do this in config
'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => false,
'rules' => array(
'mypagename' => 'modulename/controllername/actionname'
//any number of url's can be changed from here and no js is needed
)
),
Here I can give any name as my page name and as many as url's I like
I have url: /profile/profileBase/index where "profile" is module, "profileBase" is controller and "index" is action.
I want to url manager would accept route like: /profile/read/index
where "read" could be alias of controller.
Is there any way to do this using url manager rules?
Thanks
'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => false,
'rules' => array(
'profile/read/index '=>'profile/profileBase/index'
),
),
You should simply add the following rule in urlManager config :
'profile/read/index'=>'profile/profileBase/index',