Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

187 lines (149 sloc) 7.121 kb
orphan:

Zend\Navigation\Page\Mvc

MVC pages are defined using MVC parameters known from the Zend\Mvc component. An MVC page will use Zend\Mvc\Router\RouteStackInterface internally in the getHref() method to generate hrefs, and the isActive() method will compare the Zend\Mvc\Router\RouteMatch params with the page's params to determine if the page is active.

Note

Starting in version 2.2.0, if you want to re-use any matched route parameters when generating a link, you can do so via the "useRouteMatch" flag. This is particularly useful when creating segment routes that include the currently selected language or locale as an initial segment, as it ensures the links generated all include the matched value.

MVC page options
Key Type Default Description
action String NULL Action name to use when generating href to the page.
controller String NULL Controller name to use when generating href to the page.
params Array array() User params to use when generating href to the page.
route String NULL Route name to use when generating href to the page.
routeMatch Zend\Mvc\Router\RouteMatch NULL RouteInterface matches used for routing parameters and testing validity.
useRouteMatch Boolean FALSE If true, then getHref method will use the routeMatch parameters to assemble the URI
router Zend\Mvc\Router\RouteStackInterface NULL Router for assembling URLs

Note

The URI returned is relative to the baseUrl in Zend\Mvc\Router\Http\TreeRouteStack. In the examples, the baseUrl is '/' for simplicity.

getHref() generates the page URI

This example show that MVC pages use Zend\Mvc\Router\RouteStackInterface internally to generate URIs when calling $page->getHref().

isActive() determines if page is active

This example show that MVC pages determine whether they are active by using the params found in the route match object.

Using routes

Routes can be used with MVC pages. If a page has a route, this route will be used in getHref() to generate the URL for the page.

Note

Note that when using the route property in a page, you do not need to specify the default params that the route defines (controller, action, etc.).

Jump to Line
Something went wrong with that request. Please try again.