Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
67 lines (51 sloc) 2.86 KB

Omeka_View_Helper_Url

Package: :doc:`View\\Helper </Reference/packages/View/Helper/index>`

.. php:class:: Omeka_View_Helper_Url

extends :php:class:`Zend_View_Helper_Abstract`

.. php:method:: 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.

    :type $options: string|array
    :param $options:
    :type $name: string|null|array
    :param $name: 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.
    :type $queryParams: array
    :param $queryParams: Optional Set of query string parameters.
    :type $reset: bool
    :param $reset: 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.
    :type $encode: bool
    :param $encode:
    :returns: string
You can’t perform that action at this time.