Image Caption
Showing posts with label Add php file to joomla. Show all posts
Showing posts with label Add php file to joomla. Show all posts

Sunday, January 29, 2012

Create PHP file in joomla 1.5

<?php

define( 'DS', DIRECTORY_SEPARATOR );
$rootFolder = explode(DS,dirname(__FILE__));

//current level in  directory structure 
//example : (components/com_banner/view/tpl/   >>> $currentfolderlevel = 4;)
$currentfolderlevel = 4;

array_splice($rootFolder,-$currentfolderlevel);

$base_folder = implode(DS,$rootFolder);


if(is_dir($base_folder.DS.'libraries'.DS.'joomla'))
{

define( '_JEXEC', 1 );

define(JPATH_BASE,implode(DS,$rootFolder));

require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$userid='';
$usertype='';
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
$user =& JFactory::getUser();
$userid = $user->get('id');
$usertype = $user->get('usertype');
}
?>