Difference between revisions of "JURI/base"

From Joomla! Documentation

(Incorrect, and removed: "If Joomla has been installed in the web server's document root then this method will return "/" for the path." Also false/true trailing slash comment was mixedup.)
m (See also: re-categorisation)
Line 31: Line 31:
* [[JURI/current|JURI::current]]
* [[JURI/current|JURI::current]]
* [[JURI/root|JURI::root]]
* [[JURI/root|JURI::root]]

Revision as of 10:32, 9 August 2012

A static method that returns the base URI of the Joomla site.


string base( $pathonly )


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 false (default) the URI returned has a trailing "/", but when true the trailing "/" is omitted. false


In a template you can use the shortcut $this->baseurl instead of JURI::base( true ).


In this example, the Joomla site URI is shown with both values of the argument.

echo 'Joomla base URI is ' . JURI::base() . "\n";
echo 'Joomla base URI (path only) is ' . JURI::base( true ) . "\n";

might output

Joomla base URI is http://localhost/joomla/
Joomla base URI (path only) is /joomla

See also