5

Can't figure out how to import php files into my joomla component- all of these fail:

  • require_once('code.php');
  • require_once(dirname(FILE).DS.'code.php');
  • require_once(JPATH_COMPONENT.DS.'code.php' );

Any ideas? thanks

Yarin
  • 173,523
  • 149
  • 402
  • 512
  • How do they fail? Do you get any error messages? Try writing the path you think you're accessing to the error log: error_log(JPATH_COMPONENT.DS.'code.php'). This will write tne evaluated path to your error log; it may turn out that it's not what you think it is. I've used require_once( JPATH_COMPONENT.DS.'reportHelpers.php'); where reportHelpers.php is in the same directory as the file I'm using the require_once in. – EmmyS Dec 03 '10 at 21:24

3 Answers3

2

require_once(JPATH_COMPONENT_SITE.'/path/inside/your/component/folder.php');

Also - don't use DS - it is deprecated in Joomla 3.0

Søren Beck Jensen
  • 1,676
  • 1
  • 12
  • 22
1

Try jimport, see Joomla's docs on this: http://docs.joomla.org/Jimport

jimport('joomla.application.component.controller');

This will include the php file "/libraries/joomla/application/component/controller.php".

Martin
  • 10,294
  • 11
  • 63
  • 83
  • 1
    This is for joomla base libraries, found in the root joomla directory. I'm need php code that is part of my custom component, in my component directory. – Yarin Nov 30 '10 at 17:47
0

Usually these are included in a helper.php file

require_once dirname(__FILE__).'/helper.php';
idea34
  • 713
  • 5
  • 10