Answer the question
In order to leave comments, you need to log in
How to make CNC on a category/product in Yii1 and merge a slash between them?
Good afternoon,
Now I have a method for the link in the Products class:
public function getUrl() {
return Yii::app()->createUrl('/products/view', [
'id' => $this->id,
'category' => $this->category->name_alias,
'alias' => $this->name_alias,
]);
}
public function relations() {
return [
'category' => [self::BELONGS_TO, 'CategoryProducts', 'category_id'],
];
}
'/' => 'site/index',
'<action:(login|logout|registration)>' => 'users/<action>',
'<action:(contact)>' => 'site/<action>',
'products/<id:\d+>/<category:[\w_-]+>/<alias:[\w_-]+>' => 'products/view',
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'products/<id:\d+>/<alias:[\w_-]+>' => 'products/item',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
/** Менеджер */
'<module:smanager>' => '<module>/orders/index',
'<module:smanager>/<controller:\w+>/<id:\d+>' => '<module>/<controller>/view',
'<module:smanager>/<controller:\w+>' => '<module>/<controller>/index',
'<module:smanager>/<controller:\w+>/<action:\w+>/<id:\d+>' => '<module>/<controller>/<action>',
'<module:smanager>/<controller:\w+>/<action:\w+>' => '<module>/<controller>/<action>',
Answer the question
In order to leave comments, you need to log in
Tyk
You have exactly the same principle. just repeat like that. and then change to your naming.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question