Joomla! Programmierung/Framework/JURI/root
Aus Joomla! Dokumentation
ToDo JURI/root 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.
Inhaltsverzeichnis |
[Bearbeiten] Syntax
static root( [$pathonly], [$path] )
- @return string The root URI string
- @since 1.5
| Parameter | Datentyp | Beschreibung | Standardwert |
|---|---|---|---|
| [$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. | null |
[Bearbeiten] Beispiel
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
[Bearbeiten] Siehe auch
- JURI->root() auf api.joomla.org
- JURI::base
- JURI::current
[Bearbeiten] Source code
{ // Get the scheme { $uri = self::getInstance(self::base()); } // Get the scheme { self::$root['path'] = $path; } return $pathonly === false ? self::$root['prefix'] . self::$root['path'] . '/' : self::$root['path']; }