J
J
JohnDaniels2018-04-29 18:04:08
Yii
JohnDaniels, 2018-04-29 18:04:08

How to get rid of %2F in YII2 url?

I need to create a link like

/category/subcategory/subsubcategory
.
The code is something like this:
<a href="<?= Url::to([
                '3dmodels/'.$cat->getFullUrl(),
                'sort' =>  Yii::$app->request->get('sort'),
                'filter' =>  Yii::$app->request->get('filter')
        ])?>"> <?= $cat->name?> </a>

public  function getFullUrl()
    {
        $cat = $this;
        $url = '';

        if($cat->parent){
            while($cat->parent){
                $cat = $cat->parent;
                $url = $cat->slug."/".$url;
            }
            $url = $url.$this->slug;
        }
        else{
            $url = $this->slug;
        }

        return $url;
    }

the link works and looks correct,
5ae5ddbf31781657273391.png
but the method
Url::current()
, through which the rest of the links on the page are formed returns
/3dmodels/interer%2Ffurniture%2Fspalnye_garnitury

and those links don't work anymore.
Question: why does the first slash work "as is", while the rest (from the getFullUrl() method) turn into %2F ?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question