JURI/root
From Joomla! Documentation
< JURI(Difference between revisions)
(New page: A static method that returns the root URI of the Joomla site. If Joomla has been installed in the web server's document root then this method will return "/" for the path. ===Syntax=== st...) |
m (→See also: re-categorisation) |
||
| (One intermediate revision by one user not shown) | |||
| Line 1: | Line 1: | ||
A static method that returns the root URI of the Joomla site. If Joomla has been installed in the web server's document root then this method will return "/" for the path. | A static method that returns the root URI of the Joomla site. If Joomla has been installed in the web server's document root then this method will return "/" for the path. | ||
===Syntax=== | ===Syntax=== | ||
| − | string | + | string root( $pathonly, $path ) |
where: | where: | ||
| Line 44: | Line 44: | ||
* [[JURI/base|JURI::base]] | * [[JURI/base|JURI::base]] | ||
* [[JURI/current|JURI::current]] | * [[JURI/current|JURI::current]] | ||
| − | <noinclude> | + | <noinclude>[[Category:JURI]]</noinclude> |
Revision as of 11:35, 9 August 2012
A static method that returns the root URI of the Joomla site. If Joomla has been installed in the web server's document root then this method will return "/" for the path.
Syntax
string root( $pathonly, $path )
where:
| Argument | Data type | Description | Default |
|---|---|---|---|
| $pathonly | boolean | If true then only the path to the Joomla site is returned; otherwise the scheme, host and port are prepended to the path. Note that when true the URI returned has a trailing "/", but when false the trailing "/" is omitted. | false |
| $path | string | Path to override the actual path. Since this is held statically it will affect all subsequent calls to this method. |
Example
In this example, the Joomla root URI is shown with both values of the $pathonly argument. A new path is also applied and it should be noted that it affects subsequent calls to this method.
echo 'Joomla root URI is ' . JURI::root() . "\n"; echo 'Joomla root URI (path only) is ' . JURI::root( true ) . "\n"; echo 'Joomla root URI (path specified) is ' . JURI::root( false, '/a-different-path' ) . "\n"; echo 'Joomla root URI (path only) (path specified) is ' . JURI::root( true, '/a-different-path' ) . "\n"; echo "\n"; echo 'Joomla root URI is ' . JURI::root() . "\n"; echo 'Joomla root URI (path only) is ' . JURI::root( true ) . "\n";
might output
Joomla root URI is http://localhost/joomla15svn10812/ Joomla root URI (path only) is /joomla15svn10812 Joomla root URI (path specified) is http://localhost/a-different-path/ Joomla root URI (path only) (path specified) is /a-different-path Joomla root URI is http://localhost/a-different-path/ Joomla root URI (path only) is /a-different-path