How to Access Joomla! Base URI?
This is a quick tip about Joomla! development. Sometimes you, as a Joomla! developer need to create a link to the Joomla! base or somewhere else in Joomla! websites. If everything is stable and won’t change in the future, you can create an static link like
http://site.com/components/com_content/views. But the more clever and predicting way to link to somewhere in Joomla! is using base uri as the starting point of the path. In this case we redo the link above like below:
As you see, the key of this subject is
JURI::root(). It’s in PHP programming language and you can use it in your template/extension PHP files. The way you can use it is clearly described below.
This link is written in PHP so you can use it in your HTML code like this:
<?php echo JURI::root().’components/com_content/views’; ?>