Hi,
recently Im working on custom Joomla component. And I need Joomla core functions in some external scripts(that are not part of Joomla framework).
Let's say I have component and its custom class, that are not part of Joomla structure.
www.url.com/components/com_customcomp/custom_classes/some_class.php
So, I load Joomla classes into it:
if (!defined('JPATH_COMPONENT') or !constant('JPATH_COMPONENT')){
define( '_JEXEC', 1 ); //let direct access
define( 'JPATH', $_SERVER['DOCUMENT_ROOT']);
define( 'JPATH_BASE', $_SERVER['DOCUMENT_ROOT'] . '/administrator' );
define( 'DS', DIRECTORY_SEPARATOR );
define('JPATH_COMPONENT', JPATH_BASE.DS.'components'.DS.'com_customcomp');
//load joomla framework
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php');
require_once( JPATH_LIBRARIES .DS.'joomla'.DS.'factory.php');
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
}
Everything works fine except some Joomla core functions, like JURI::root(); which returns:
www.url.com/components/com_customcomp/custom_classes
Instead of:
www.url.com/
Also some strange results give JRoute::_() and etc.
What is the problem ? How to make that functions to work properly ?
Your help would be appreciated.
Can you try setting "live_site" in your global configuration.php file
and see if that helps?
- Ken
--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.
function getHelpers()
{
$classpath = JPATH_ROOT .DS.'components'.DS.'com_yourcomponent'.DS.'helpers';
$hide = array('index.html', 'json.php', 'loader.php');
foreach( JFolder::files($classpath) as $file )
{
if(!in_array($file, $hide))
{
$name = ucfirst(JFile::stripExt($file));
$class = 'MYhelper' . $name;
JLoader::register($class , $classpath.DS.$file);
}
}
}