1

I Have a problem about require_once in joomla.

In this file php:

components\com_test\views\__test_r5\tmpl\default.php

I want to include some file using this code:

require_once (JPATH_ROOT.DS.'/includes/General.php');

but require_once does not works

j0k
  • 22,600
  • 28
  • 79
  • 90
user1798056
  • 29
  • 2
  • 4
  • I have no idea what you are trying to achieve. Please explain in more detail what you need. – Lodder Nov 04 '12 at 13:43

3 Answers3

5

The path you are trying to include will evaluate to something like: joomla//includes/General.php. Notice the double slashes before "includes". The constant DS is defined to be a directory separator.

Try:
require_once (JPATH_ROOT.'/includes/General.php');
 (without DS)

Matteus Hemström
  • 3,796
  • 2
  • 26
  • 34
0

Try This :

require_once(JPATH_SITE.DS."includes/General.php");

The JPATH_SITE will return your physical path upto : installation folder.

also JURI::root() will return your site url
Jobin
  • 8,238
  • 1
  • 33
  • 52
0

The best way to do this is to use @Fnatte variant.

Also have a look at the Joomla! constants definitions and adapt where needed.

Valentin Despa
  • 40,712
  • 18
  • 80
  • 106