tags:

views:

32

answers:

1

Given in routing.yml:

products:
url:   /products/*
param: { module: products, action: index }

How to fill wildcard part using url_for helper? I mean somthing like:

<?= url_for('products/index?wildcard=somthingRandom') ?>

that generates URL:

/products/somethingRandom
+3  A: 

Change your routing.yml to have a parameter in the matched URL:

products:
url:   /products/:wildcard
param: { module: products, action: index }

Then you can invoke url_for eg:

<?php echo url_for("@products?wildcard=somethingRandom"); ?>

(using @products means use the route named products in your routing.yml.)

richsage
That's exactly how to do it. I prefer to use the array syntax: url_for("@products", array('wildcard' => 'somethingRandom'))
Marc
@Marc yep - definitely nicer to read, particularly if you have lots of parameters in your URL ;-)
richsage