2

I have the following directory structure:

C:\mywebsites
  \site_1
  \site_2
  \site_n

In 'site_2' I have joomla installed, however, I have other folders with resources, php scripts, etc. in one of the 'extra' folders, I have scripts that I'm frequently calling, the trouble comes when I call JURI::base(), it returns the folder in which the script file is, in stead of 'site_2' which I'm expecting.

How can I overcome this simple task?

hakre
  • 193,403
  • 52
  • 435
  • 836
  • I'm looking for a more elegant solution, right now I'm using str_replace to remove extra folders, however, it would be nice if I could get "C:\mywebsites\site_2" by calling one function from a script located in "C:\mywebsites\site_2\a\few\folders\deep\php\script.php" –  Jan 26 '12 at 19:15

3 Answers3

4

The root directory is defined in JPATH_BASE.

It's set in the index.php in the Joomla front end and in the /administrator using:

define('JPATH_BASE', dirname(__FILE__));

JURI::base() returns the base request path.

Craig
  • 9,335
  • 2
  • 34
  • 38
3

define('JPATH_BASE', dirname(FILE));

is return your local drive path.. means c:/site_1/site_2/site_3/

JURI::base()

is return the livefolder path... means http://localhost/site_1/site_2/site_3/

KiNG H
  • 161
  • 1
  • 14
2

Using JPATH_ROOT will give you the path to the joomla installed site.

http://docs.joomla.org/Constants

Gavin Bruce
  • 1,799
  • 16
  • 28