Specify path to external scripts (internal to the server)

102 Views Asked by At

I've a custom script to include into Joomla 3.x page. This script is into folder "foo" on the Joomla installation root. This script has inside references to others secondary scripts in its own folder. For make this I've used a "content plugin" that permit the script execution.

The problem is that this plugin execute the php script as if it were in the installation root and not in the folder "/foo" Running the script in this way, the others secondary scripts are not seen it.

Then I've set the php path variable into the script, but it not solve:

ini_set('include_path', 'foo');

How could be possible to handle this kind of situations?

1

There are 1 best solutions below

0
On

Import the script with the JLoader, like:

JLoader::import('foo.bar', JPATH_ROOT);

This assumes that you have a PHP file bar.php in the foo folder of your Joomla root. The other scripts must handle their includes correctly when you don't want to include them trough the JLoader (then they are not standalone anymore).