JURI/root
From Joomla! Documentation
< JURI(Difference between revisions)
m |
m (Edit api.joomla.org link) |
||
| (One intermediate revision by one user not shown) | |||
| Line 41: | Line 41: | ||
Joomla root URI (path only) is /a-different-path | Joomla root URI (path only) is /a-different-path | ||
===See also=== | ===See also=== | ||
| − | * [http://api.joomla.org/Joomla-Framework/Environment/JURI.html#root JURI::root on api.joomla.org] | + | * [http://api.joomla.org/1.5/Joomla-Framework/Environment/JURI.html#root JURI::root on api.joomla.org] |
* [[JURI/base|JURI::base]] | * [[JURI/base|JURI::base]] | ||
* [[JURI/current|JURI::current]] | * [[JURI/current|JURI::current]] | ||
| − | <noinclude> | + | <noinclude>[[Category:JURI]]</noinclude> |
Latest revision as of 12:35, 21 December 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.
[edit] 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. |
[edit] 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