View Helper - URL¶
Basic Usage¶
url($name, $urlParams, $routeOptions, $reuseMatchedParams): Creates a URL string based on a named route. $urlParams should be an associative array of key/value pairs used by the particular route.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | // In a configuration array (e.g. returned by some module's module.config.php)
'router' => array(
'routes' => array(
'auth' => array(
'type' => 'segment',
'options' => array(
'route' => '/auth[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'controller' => 'auth',
'action' => 'index',
),
)
)
)
),
// In a view script:
<a href="<?php echo $this->url('auth', array('action' => 'logout', 'id' => 100)); ?>">Logout</a>
|
Output:
1 | <a href="/auth/logout/100">Logout</a>
|