A
A
Alexander Ivanov2017-05-03 20:49:24
Yii
Alexander Ivanov, 2017-05-03 20:49:24

Why does one rule for different post categories url in Yii2 not work correctly?

'rules' => [
                ''=>'site/index',
                'sitemap.xml' => 'sitemap/index',
                '<module:\w+>/<uri:\w+>' => '/<module>/default/view', 
                '<controller:\w+>/<id:\d+>'=>'<controller>/view',
                '<action:\w+>'=>'site/<action>',
            ]


//------- вывожу вид  
//------- данные внизу одинаковы для разделов УСЛУГИ и БЛОГ

use Yii;
...
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\web\UploadedFile;
use yii\helpers\Url;


    public function actionView($uri)
    {
        $model = $this->render('view', [
          'model' => Posts::findOne(['url' => $uri]),
        ]);
        return $model;
    }


// 404
    public function actionView($uri)
    {
        $model = $this->render('view', [
          'model' => Services::findOne(['url' => $uri]),
        ]);
        return $model;
    }

I read the material
about the transfer to the action. As a result, the blog has $uri = "text" and the services have $uri = "value in id"
Why are services displayed by id and the blog by uri
Where can be the root of the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ivanov, 2017-05-03
@cimonlebedev

I don't know what the joke was. in general, the site was on tilde, of course, under tilde, there was no desire to make a cool admin panel, in general, transferred the database and the entire site .. Apparently, records from a different site somehow incorrectly affected the work and the moderator somehow crookedly filled in general when deleting records from db and creating new ones worked)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question