Hi guys,
I have a question about Url management:
In web.php configuration ( I am using basic template )
'urlManager' => [
'class' => 'yii\web\UrlManager',
// Disable index.php
'showScriptName' => false,
// Disable r = routes
'enablePrettyUrl' => true,
'rules' => array(
'activities/more/<page:\d+>' => 'activities/more',
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
),
],
I added
'activities/more/<page:\d+>' => 'activities/more',
and controller
public function actionMore($page = 1)
{
$activities = Activity::find()
->orderBy('id DESC')
->limit(5)
->offset(($page - 1) * 5)
->all();
if (!empty($activities)) {
return $this->renderPartial('@widget/views/activities/_list', [
'errors' => '',
'activities' => $activities
]);
}
else {
echo "<p class='no-more'>No activity is available</p>";
exit();
}
}
and it’s working for me.
But when in web.php configuration :
I want to set
'activities/viewmore/<page:\d+>' => 'activities/viewmore',
instead of
'activities/more/<page:\d+>' => 'activities/more',
and in controller
public function actionViewMore($page=1) {
.....
....
}
but it’s not working anymore. I don’t know what’s issue? Please help me.
Thanks in advance