# \[Slim 2\] do not allow urlFor() to output dummy variable for optional route parameter

**URL:** https://discourse.slimframework.com/t/slim-2-do-not-allow-urlfor-to-output-dummy-variable-for-optional-route-parameter/468
**Category:** Questions
**Created:** [July 3, 2016, 7:25pm UTC](https://discourse.slimframework.com/t/slim-2-do-not-allow-urlfor-to-output-dummy-variable-for-optional-route-parameter/468 "2016-07-03T19:25:42Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ziriusph](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/ziriusph/32/97_2.png) [@ziriusph](https://discourse.slimframework.com/u/ziriusph)
#### Post date: [July 3, 2016, 7:25pm UTC](https://discourse.slimframework.com/t/slim-2-do-not-allow-urlfor-to-output-dummy-variable-for-optional-route-parameter/468/1 "2016-07-03T19:25:42Z")

</div>

I just want to know if there’s a trick for this.Say I have a route with optional variable `$mod`:

```
$app->get('/categories(/edit-:mod)', function($mod = 0) use ($app) {
}->name('category')

```

if I call its `urlFor('category')` it would output:

```
/categories/edit-:mod

```

even I did not supply parameter to `:mod`, is there a way to just make the output

```
/categories

```

since I do not want to to have the dummy variable and parameter to always show at the default link

Thanks!

---

<div class="post-metadata">

### Author: ![geggleto](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/geggleto/32/11_2.png) [@geggleto](https://discourse.slimframework.com/u/geggleto)
#### Post date: [July 8, 2016, 12:46pm UTC](https://discourse.slimframework.com/t/slim-2-do-not-allow-urlfor-to-output-dummy-variable-for-optional-route-parameter/468/2 "2016-07-08T12:46:22Z")

</div>

I do not believe this is a feature in Slim 2 and we aren’t currently developing new features for Slim 2 we are looking at stuff for 4.0

That said, you could hack together something that would solve your immediate problem…

Example:

```auto
$uri = "/categories/edit-:mod"; // urlFor
$uri = substr($uri, 0, strrpos($uri, "/")); // /categories

```
