P
P
Pavel Gogolinsky2014-06-16 09:17:05
Yii
Pavel Gogolinsky, 2014-06-16 09:17:05

How to organize mixed URL in YII?

I want to get such a URL
site.ru/catalog/list?sort= "name"&dir="DESC"
That is, so that the main url (with the controller and action) is CNC, and additional parameters are passed after the question mark.
I write like this:

$this->createUrl('catalog/list', array(
            'id' => $this->cat_id,
            'sort_type' => $this->sort_type,
            'direction_type' => $this->direction_type,
        ));

I get:
http://guard.ru/catalog/id/17/sort_type/price/direction_type/DESC

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Gamayunov, 2014-06-25
@gogolinsky

You need to add a rule with a named parameter id to the routing.
Then id will be part of the URL, and the rest of the arguments will become GET parameters. The output will be:/catalog/17?sort_type=name&direction_type=DESC

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question