September 03 2014

Joomla return site root or main url

Tagged Under :

Joomla
In Joomla the easy way to get complete site domain with the specified folder (if your joomla put in others folder). You can use JURI::root() this function to get it.

How to use this feature:
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 'Joomla root URI is '.JURI::root()."\n";
echo 'Joomla root URI (path only) is '.JURI::root( true )."\n";
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

Make a Comment

You must be logged in to post a comment.