O
O
Oleg Titarenko2015-03-19 11:09:40
Yii
Oleg Titarenko, 2015-03-19 11:09:40

How to make url displayed inline in YII2?

I have a URL rule, but I can't get it to convert the URL to string form. Since the site actually creates duplicate pages.

public function actionP($category, $brand, $product) {
        $model = Product::getBolleanProduct($category, $brand, $product);
        if($model['product_id'] && $model['category_id'] && $model['manufacturer_id']) {
           return $this->getProduct($model['product_id'], $category, $brand, $product);
        } else {
            throw new \yii\web\HttpException(404, '404! Товар не найден');
        }
    }

Tell me how to set up a rule?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oleg Titarenko, 2015-03-19
@olegtytarenko2

So I decided, of course, the method is rude, but it works

public function actionP($category, $brand, $product) {
        $model = Product::getBolleanProduct($category, $brand, $product);
        if($model['product_id'] && 
                $model['category_id'] && 
                $model['manufacturer_id'] && 
                $product === strtolower($product) && 
                $brand === strtolower($brand) && 
                $category === strtolower($category)) {
           return $this->getProduct($model['product_id'], $category, $brand, $product);
        } else {
            throw new \yii\web\HttpException(404, '404! Товар не найден');
        }
    }

M
Maxim Grechushnikov, 2015-03-19
@maxyc_webber

blabla/< category>/< brand>/< product> => blabla/shop/P

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question