Answer the question
In order to leave comments, you need to log in
How to get rid of %2F in YII2 url?
I need to create a link like
/category/subcategory/subsubcategory.
<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;
}
Url::current(), through which the rest of the links on the page are formed returns
/3dmodels/interer%2Ffurniture%2Fspalnye_garnitury
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question