I am new to ZF2. I have question for url('route-name', $urlParams, $urlOptions); ?>
What should I construct $urlParams and $urlOptions when multiple controller in module?
I rename Album module as Shop and it has two controllers: indexController and VendorController. In the View>Shop>Vendor>index.phtml, I add:
<p><a href="<?php echo $this->url('shop', array('action'=>'add')); ?>">
Add new vendor</a></p>
aiming this link would links to localhost/shop/vendor/add. But the page shows the link is: http://host.com/shop while what i want is http://host.com/shop/vendor/add
My understanding is that I should set $urlOPtions field, could anyone give me example? Thanks all Below is module.config.php:
'router' => array(
'routes' => array(
'shop' => array(
'type' => 'Literal',
'options' => array(
'route' => '/shop',
'defaults' => array(
'__NAMESPACE__' => 'Shop\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '/[:controller[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
),
),
),
),
),
),
),
'controllers' => array(
'invokables' => array(
'Shop\Controller\Index' => 'Shop\Controller\IndexController',
'Shop\Controller\Vendor'=> 'Shop\Controller\VendorController'
),
),