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

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!

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:

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