简体   繁体   中英

PHP include in Joomla! 1.7

I need to include a file in one of my components in Joomla!. The file I want to include is located in the root of my Joomla! directory (where my index.php file is but my the file where the include is going is deeper in the administrator folder. It is in this file:

administrator/components/com_rsform/helpers/rsform.php

How can i put an include in that file that will link back to the file in my root of Joomla!? I need the path to be relative so that it is environment independent. Thanks in advance for your help!

Try the following:

<?php include_once (JPATH_ADMINISTRATOR .DS. 'components'.DS.'com_rsform'.DS.'helpers'.DS.'rsform.php'); ?>

There are also other variables that may help you:

JPATH_SITE = /your_local_path_to_site/ ie: /var/www/mysite

JPATH_COMPONENT = /your_local_path_to_site/components/the_component_you_are_in ie: /var/www/mysite/componentes/com_rsform

Hope that helps!

JPATH_SITE is constant always contains a path on the server's file system.

Please have a look onto this one.

http://www.latenight-coding.com/joomla-faqs/developers/get-path-joomla-folder.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM