K
K
kapai692015-04-29 12:57:25
symfony
kapai69, 2015-04-29 12:57:25

Optional first parameter in routing?

How to get rid of the first parameter if necessary? For example, there is a routing

index:
    path:     /{category}/{item}
    defaults: { _controller: AppTestBundle:Test:index, category = mainCategory }

If you do not pass the category, then this route does not work, you have to pervert, something like
index:
    path:     /{item}
    defaults: { _controller: AppTestBundle:Test:index }

indexWithCat:
    path:     /{category}/{item}
    defaults: { _controller: AppTestBundle:Test:index, category = mainCategory }

How to do it right?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis, 2015-04-29
@prototype_denis

Why don't you read the documentation ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question