Actions

Difference between revisions of "JURI/base"

From Joomla! Documentation

(New page: A static method that returns the base 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 (Edit api.joomla.org link)
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
A static method that returns the base 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 base URI of the Joomla site.   
 
===Syntax===
 
===Syntax===
 
string base( $pathonly )
 
string base( $pathonly )
Line 12: Line 12:
 
|$pathonly
 
|$pathonly
 
|boolean
 
|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.
+
|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'''
 
|'''false'''
 
|}
 
|}
  
 +
===Note===
 +
In a template you can use the shortcut <code>$this->baseurl</code> instead of <code>JURI::base( '''true''' )</code>.
 
===Example===
 
===Example===
 
In this example, the Joomla site URI is shown with both values of the argument.
 
In this example, the Joomla site URI is shown with both values of the argument.
Line 26: Line 28:
 
  Joomla base URI (path only) is /joomla
 
  Joomla base URI (path only) is /joomla
 
===See also===
 
===See also===
* [http://api.joomla.org/Joomla-Framework/Environment/JURI.html#base JURI::base on api.joomla.org]
+
* [http://api.joomla.org/1.5/Joomla-Framework/Environment/JURI.html#base JURI::base on api.joomla.org]
 
* [[JURI/current|JURI::current]]
 
* [[JURI/current|JURI::current]]
 
* [[JURI/root|JURI::root]]
 
* [[JURI/root|JURI::root]]
<noinclude>[[Category:Development]][[Category:Framework]][[Category:JURI]]</noinclude>
+
<noinclude>[[Category:JURI]]</noinclude>

Latest revision as of 12:35, 21 December 2012

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

Contents

Syntax

string base( $pathonly )

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

Note

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

Example

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