Function Summary
-
_encodeText($text)
-
string
link_to_unless($condition, $name = '', $internal_uri = '', $options = array())
If the condition passed as first argument is false, creates a <a>
link tag of the given name using a routed URL based on the module/action
passed as argument and the routing configuration.
-
string
button_to($name, $internal_uri = '', $options = array())
Creates an <input> button tag of the given name pointing to a routed
URL based on the module/action passed as argument and the routing
configuration.
-
_confirm_javascript_function($confirm)
-
string
link_to($name = '', $internal_uri = '', $options = array())
Creates a <a> link tag of the given name using a routed URL based on
the module/action passed as argument and the routing configuration.
-
string
link_to_if($condition, $name = '', $internal_uri = '', $options = array())
If the condition passed as first argument is true, creates a <a>
link tag of the given name using a routed URL based on the module/action
passed as argument and the routing configuration.
-
_popup_javascript_function($popup, $url = '')
-
_post_javascript_function()
-
string
url_for($internal_uri, $absolute = false)
Returns a routed URL based on the module/action passed as argument and the
routing configuration.
-
string
mail_to($email, $name = '', $options = array(), $default_value = array())
Creates a <a> link tag to the given email (with
href="mailto:...").
-
_convert_options_to_javascript($html_options, $url = 'this.href')
-
The
public_path($path, $absolute = false)
Returns a URL rooted at the web root
Function Details
-
_encodeText ($text)
-
(string) link_to_unless ($condition, $name = '', $internal_uri = '', $options = array())
| $condition |
condition |
| $name |
name of the link, i.e. string to appear between the <a> tags |
| $internal_uri |
'module/action' or '@rule' of the action |
| $options |
additional HTML compliant <a> tag parameters |
If the condition passed as first argument is false, creates a <a>
link tag of the given name using a routed URL based on the module/action
passed as argument and the routing configuration.
If the condition is true, the given name is returned between <span> tags
Options:
'tag' - the HTML tag that must enclose the name if the condition is true, defaults to <span>
'absolute' - if set to true, the helper outputs an absolute URL
'query_string' - to append a query string (starting by ?) to the routed url
'anchor' - to append an anchor (starting by #) to the routed url
'confirm' - displays a javascript confirmation alert when the link is clicked
'popup' - if set to true, the link opens a new browser window
'post' - if set to true, the link submits a POST request instead of GET (caution: do not use inside a form)
Examples: echo link_to_unless($user->isAdministrator(), 'Delete this page', 'my_module/my_action');
=> <span>Delete this page</span>
echo link_to_unless(!$user->isAdministrator(), 'Delete this page', 'my_module/my_action');
=> <a href=\"/path/to/my/action\">Delete this page</a>
returns XHTML compliant <a href> tag or name
-
(string) button_to ($name, $internal_uri = '', $options = array())
| $name |
name of the button |
| $internal_uri |
'module/action' or '@rule' of the action |
| $options |
additional HTML compliant <input> tag parameters |
Creates an <input> button tag of the given name pointing to a routed
URL based on the module/action passed as argument and the routing
configuration.
The syntax is similar to the one of link_to.
Options:
'absolute' - if set to true, the helper outputs an absolute URL
'query_string' - to append a query string (starting by ?) to the routed url
'anchor' - to append an anchor (starting by #) to the routed url
'confirm' - displays a javascript confirmation alert when the button is clicked
'popup' - if set to true, the button opens a new browser window
'post' - if set to true, the button submits a POST request instead of GET (caution: do not use inside a form)
Examples: echo button_to('Delete this page', 'my_module/my_action');
=> <input value=\"Delete this page\" type=\"button\" onclick=\"document.location.href='/path/to/my/action';\" />
returns XHTML compliant <input> tag
-
_confirm_javascript_function ($confirm)
-
(string) link_to ($name = '', $internal_uri = '', $options = array())
| $name |
name of the link, i.e. string to appear between the <a> tags |
| $internal_uri |
'module/action' or '@rule' of the action |
| $options |
additional HTML compliant <a> tag parameters |
Creates a <a> link tag of the given name using a routed URL based on
the module/action passed as argument and the routing configuration.
It's also possible to pass a string instead of a module/action pair to get a link tag that just points without consideration. If null is passed as a name, the link itself will become the name. If an object is passed as a name, the object string representation is used. One of the options serves for for creating javascript confirm alerts where if you pass 'confirm' => 'Are you sure?', the link will be guarded with a JS popup asking that question. If the user accepts, the link is processed, otherwise not.
Options:
'absolute' - if set to true, the helper outputs an absolute URL
'query_string' - to append a query string (starting by ?) to the routed url
'anchor' - to append an anchor (starting by #) to the routed url
'confirm' - displays a javascript confirmation alert when the link is clicked
'popup' - if set to true, the link opens a new browser window
'post' - if set to true, the link submits a POST request instead of GET (caution: do not use inside a form)
Note: The 'popup' and 'post' options are not compatible with each other.
Examples: echo link_to('Delete this page', 'my_module/my_action');
=> <a href=\"/path/to/my/action\">Delete this page</a>
echo link_to('Visit Hoogle', 'http://www.hoogle.com');
=> <a href=\"http://www.hoogle.com\">Visit Hoogle</a>
echo link_to('Delete this page', 'my_module/my_action', array('id' => 'myid', 'confirm' => 'Are you sure?', 'absolute' => true));
=> <a href=\"http://myapp.example.com/path/to/my/action\" id=\"myid\" onclick=\"return confirm('Are you sure?');\">Delete this page</a>
returns XHTML compliant <a href> tag
-
(string) link_to_if ($condition, $name = '', $internal_uri = '', $options = array())
| $condition |
condition |
| $name |
name of the link, i.e. string to appear between the <a> tags |
| $internal_uri |
'module/action' or '@rule' of the action |
| $options |
additional HTML compliant <a> tag parameters |
If the condition passed as first argument is true, creates a <a>
link tag of the given name using a routed URL based on the module/action
passed as argument and the routing configuration.
If the condition is false, the given name is returned between <span> tags
Options:
'tag' - the HTML tag that must enclose the name if the condition is false, defaults to <span>
'absolute' - if set to true, the helper outputs an absolute URL
'query_string' - to append a query string (starting by ?) to the routed url
'anchor' - to append an anchor (starting by #) to the routed url
'confirm' - displays a javascript confirmation alert when the link is clicked
'popup' - if set to true, the link opens a new browser window
'post' - if set to true, the link submits a POST request instead of GET (caution: do not use inside a form)
Examples: echo link_to_if($user->isAdministrator(), 'Delete this page', 'my_module/my_action');
=> <a href=\"/path/to/my/action\">Delete this page</a>
echo link_to_if(!$user->isAdministrator(), 'Delete this page', 'my_module/my_action');
=> <span>Delete this page</span>
returns XHTML compliant <a href> tag or name
-
_popup_javascript_function ($popup, $url = '')
-
_post_javascript_function ()
-
(string) url_for ($internal_uri, $absolute = false)
| $internal_uri |
'module/action' or '@rule' of the action |
| $absolute |
return absolute path? |
Returns a routed URL based on the module/action passed as argument and the
routing configuration.
Examples: echo url_for('my_module/my_action');
=> /path/to/my/action
echo url_for('@my_rule');
=> /path/to/my/action
echo url_for('@my_rule', true);
=> http://myapp.example.com/path/to/my/action
returns routed URL
-
(string) mail_to ($email, $name = '', $options = array(), $default_value = array())
| $email |
target email |
| $name |
name of the link, i.e. string to appear between the <a> tags |
| $options |
additional HTML compliant <a> tag parameters |
Creates a <a> link tag to the given email (with
href="mailto:...").
If null is passed as a name, the email itself will become the name.
Options:
The mail link still works when encoded, but the address doesn't appear in clear in the source. Use it to prevent spam (efficiency not guaranteed).
Examples: echo mail_to('webmaster@example.com');
=> <a href=\"mailto:webmaster@example.com\">webmaster@example.com</a>
echo mail_to('webmaster@example.com', 'send us an email');
=> <a href=\"mailto:webmaster@example.com\">send us an email</a>
echo mail_to('webmaster@example.com', 'send us an email', array('encode' => true));
=> <a href=\"mailto:webmaster@example.com\">send us an email</a>
returns XHTML compliant <a href> tag
-
_convert_options_to_javascript ($html_options, $url = 'this.href')
-
(The) public_path ($path, $absolute = false)
| $path |
The route to append |
| $absolute |
If true, an absolute path is returned (optional) |
Returns a URL rooted at the web root
returns web URL root
|