Omeka_View_Helper_Url

Package: View\Helper

class Omeka_View_Helper_Url

extends Zend_View_Helper_Abstract

Omeka_View_Helper_Url::url($options = array(), $name = null, $queryParams = array(), $reset = false, $encode = true)

Generate a URL for use in one of Omeka’s view templates.

There are two ways to use this method. The first way is for backwards compatibility with older versions of Omeka as well as ease of use for theme writers.

Here is an example of what URLs are generated by calling the function in different ways. The output from these examples assume that Omeka is running on the root of a particular domain, though that is of no importance to how the function works.

<code> echo $this->url(‘items/browse’); // outputs “/items/browse”

echo $this->url(‘items/browse’, array(‘tags’=>’foo’)); // outputs “/items/browse?tags=foo”

echo $this->url(array(‘controller’=>’items’, ‘action’=>’browse’)); // outputs “/items/browse”

echo $this->url( array(‘controller’=>’items’, ‘action’=>’browse’), ‘otherRoute’, array(‘tags’=>’foo’), ); // outputs “/miscellaneous?tags=foo” </code>

The first example takes a URL string exactly as one would expect it to be. This primarily exists for ease of use by theme writers. The second example appends a query string to the URL by passing it as an array. Note that in both examples, the first string must be properly URL-encoded in order to work. url(‘foo bar’) would not work because of the space.

In the third example, the URL is being built directly from parameters passed to it. For more details on this, please see the Zend Framework’s documentation.

In the last example, ‘otherRoute’ is the name of the route being used, as defined either in the routes.ini file or via a plugin. For examples of how to add routes via a plugin, please see Omeka’s documentation.

Parameters:
  • $options (string|array) –
  • $name (string|null|array) – Optional If $options is an array, $name should be the route name (string) or null. If $options is a string, $name should be the set of query string parameters (array) or null.
  • $queryParams (array) – Optional Set of query string parameters.
  • $reset (boolean) – Optional Whether or not to reset the route parameters implied by the current request, e.g. if the current controller is ‘items’, then ‘controller’=>’items’ will be inferred when assembling the route.
  • $encode (boolean) –
Returns:

string