File/view/lib/helpers/url_helper.php

Description

URL helpers

Functions
button_to ($label, $url_options = array(), $html_options = array())

Generates a form containing a single button that submits to the URL created by $url_options.

This is the safest method to ensure links that cause changes to your data are not triggered by search bots or accelerators. The generated form element has a class name of button-to to allow styling of the form itself and its children. This helper also accepts the confirm option.

is_current_controller ($options)

Returns true if the request uri generated by the given $options corresponds to the current controller.

is_current_page ($options)

Returns true if the current request uri could be generated by the given $options.

link_to ($label, $url_options = array(), $html_options = array())

Creates a link tag of the given $label using a URL created by passing $url_options to url_for helper.

You can also pass a string instead of an array to get a link tag that uses the value of the string as the href for the link. The $html_options will accept an array of html attributes for the link tag, and also accepts a confirm option that will add a JavaScript confirm prompt.

Example:

 link_to('Delete this item', array('action' => 'delete', 'id' => $this->item->id),
                             array('confirm' => 'Are you sure ?'));

link_to_if ($condition, $label, $url_options = array(), $html_options = array())

Creates a link tag if $condition is true.

link_to_unless ($condition, $label, $url_options = array(), $html_options = array())

Creates a link tag unless $condition is true, in which case only the $label is returned.

link_to_unless_current ($label, $url_options = array(), $html_options = array())

Creates a link tag unless the current request uri is the same as the link, in which case only the $label is returned.

url_for ($options)

Returns a URL that has been rewritten according to the $options array and the defined Routes.

Options:

  • anchor: - specifies the anchor name to be appended to the path.
  • only_path: - if true, returns the relative URL.
  • trailing_slash: - if true, adds a trailing slash.
  • host: - overrides the default (current) host if provided.
  • protocol: - overrides the default (current) protocol if provided.

Examples:

 url_for(array('controller' => 'posts', 'action' => 'show', 'id' => 10)); // -> http://myhost.com/posts/show/10
  url_for(array('controller' => 'posts', 'action' => 'list', 'only_path' => true)); // -> posts/list
  url_for(array('controller' => 'posts', 'action' => 'list', 'anchor' => '25')); // -> posts/list#25

Documentation generated on Wed, 24 Jan 2007 14:54:55 +0100 by phpDocumentor 1.3.0RC4