0 Comments   Thursday, 6th May 2010

Joomla and iFrames

On a recent project I worked on, I needed to find a way of customer details through an iFrame for processing.  After perusing through the Joomla forums on several occasions and even asking questions, I was still left without the answers I wanted.  In the end, I decided the best way of doing what I needed was to add some code from the Joomla framework into the iFrame.  This enabled me to pass session data as well several pieces of information very easy to my component's iFrame.

If you are including a external piece of code into your Joomla application and want to be able to pass information easliy, be it in an iFrame, simply add this code to the top of the file in question:

define( '_JEXEC', 1 );

// real path depending on the type of server
// change the number of returns/level needed in your path relative to the position
// of your script in your directory
if (stristr( $_SERVER['SERVER_SOFTWARE'], 'win32' )) {
    define( 'JPATH_BASE', realpath(dirname(__FILE__).'\..\..\..\..\..' ));
} else define( 'JPATH_BASE', realpath(dirname(__FILE__).'/../../../../..' ));

define( 'DS', DIRECTORY_SEPARATOR );

// loading framework of Joomla!
require_once ( JPATH_BASE.DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE.DS.'includes'.DS.'framework.php' );
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();

// if need a specific language component, you can load it here

jimport( 'joomla.plugin.plugin' );

// no direct access
session_start();

$session =& JFactory::getSession();

This should ensure that you are able to pass information easily within you application

 
Filed In: Web Development
Share |


« Previous Article Next Article »



Other Posts You Might Like


blog comments powered by Disqus

Archives

 
 

Latest Tweets

Recent Comments

Powered by Disqus

 


About Me

My name is Emmanuel Okorie. I am by profession a web designer who is trying to expand his expertise into other areas of media such as Digital Video, Photography and General Design.

You can read a bit more about me by visiting the About Me page.

 

 
[ Login ]