Adding Flex 3.0 swf to Joomla 1.6
Adding Flex 3.0 using MySQL to Joomla 1.6
I redesigned a web application to take advantage of Joomla 1.6. One of the key features of the old web site was its use of interactive charts that were created in Adobe Flex 3.0. These charts used their own MySQL DB to query data that they would display.
|joom16||Joomla 1.6 Database|
|shread||legacy database containing chart data|
This is how I included them into Joomla.
Create the environment
Within Joomla root directory, I created a new directory to hold my custom code and I named it ./user. In here is where all my custom non-joomla code exists for the website. For this tutorial we will be focusing on the ./shread directory. I don't know if creating a directory of my own is what Joomla recommends, I suspect it isn't. But I was unable to find a Joomla approved answer to this question so I just created my own.
I copied my Flex .swf files to the ./shread directory. The Action Script code for each of these files makes a call to the ./scripts/ directory where .php files are located that contain code that does the following.
- Connects to the shread database
- Makes a SQL query to get the data
- Passes the result back to the .swf via HTTPService
How this is done in ActionScript is beyond the scope of this tutorial.
I ran into some problems connecting to the database. Because my code is outside of Joomla, I was unable to use the recommended Joomla calls to JFactory. So, I had to use regular php mysqli_connect statements. I used to mysqli_connect statements, one connected to shread, and the other connected to joom16.
These steps were placed in the file named connect_to_mysql.php.
Another file named checkuserlingin.php contained code to determine the joomla user.
Find logged in user info from outside of Joomla 1.6
I have Jomsocial 2.2 also installed on this website. I did some testing and found that a common cookie named "activeProfile" contains the user_id of the jos_sessions table.
Executing the Flex swf file from inside Joomla 1.6
I created a Joomla Menu Item with type = Iframe Wrapper. In the URL I used my website root with the path to the .swf that matches the directory tree: