Skip to content
This repository has been archived by the owner on May 24, 2018. It is now read-only.

Latest commit

 

History

History
44 lines (34 loc) · 1.19 KB

zend.view.helpers.url.rst

File metadata and controls

44 lines (34 loc) · 1.19 KB

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.

// 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:

<a href="/auth/logout/100">Logout</a>