Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find Joomla root directory

Tags:

path

joomla

how to I find out the Joomla root directory to use in files? I tried the following with no luck:

    $path = JPATH_COMPONENT; 
    //Gives component root

    $path = JURI::root();
    //Gives absolute path, can't be used for some reason (http://www.site.com)

    $path = $_SERVER['DOCUMENT_ROOT'];
    //Gives public_html folder, but if someone installs joomla in a directory and not in root, it wrecks the whole thing

Is there a way to find the joomla root of the site only? Thanks.

like image 509
Mankind1023 Avatar asked Aug 17 '12 03:08

Mankind1023


2 Answers

may be this can help you http://docs.joomla.org/Constants

like image 181
Anand Avatar answered Nov 20 '22 22:11

Anand


Let's say you want to include an image from the images folder, you can simply use this:

$image = JUri::root() . 'images/image_name.png';

JUri::root() and both JUri::site() always define the root directory

like image 9
Lodder Avatar answered Nov 20 '22 23:11

Lodder