who needs social life when you have broadband?

Inventas vitam iuvat excoluisse per artes / Let us improve life through science and art.

Flash and Joomla! integration (part II )

Hello,

due to popular demand :D, I'm posting a different example to ilustrate how easy is to export Joomla! content to a XML format and then use it inside your flash movies (as you learned in the first part of this "article"). Today I'm gonna show a quick-and-dirty way to export your frontpage items.

Before we start:
- Make sure you've read the first part (link is above) of the article otherwise you won't understand nothing that is posted here.
- You don't need to change anything in the XmlGenerator class. This script will just USE it.
- I'm sorry I'm not posting the .fla, I've gotta write my final project for college and didn't have enough time to code the actionscripts (any volunteer?)

Ok, here's a small script I've wrote to export frontpage items and then generate the xml.

PHP:
  1. <?php
  2. /**
  3. * Joomla! FrontPage - XML-Generator
  4. * @author Matheus Mendes aka bigodines - http://www.joomla.com.br
  5. * @date May, 2007
  6. * @license GNU GPL v2.0
  7. *
  8. */
  9.  
  10. define('_VALID_MOS', 1);
  11. // joomla stuff :P
  12. include_once("../configuration.php");
  13. include_once("../includes/database.php");
  14. // XmlGenerator
  15. include_once("clsXmlGen.php");
  16.  
  17. $source = array();
  18. /* database object */
  19. $database = new database( $mosConfig_host, $mosConfig_user, $mosConfig_password, $mosConfig_db, $mosConfig_dbprefix );
  20.  
  21. $database->setQuery("SELECT content_id id FROM #__content_frontpage");
  22. $front_items = $database->loadObjectList();
  23.  
  24. foreach($front_items as $item) {
  25.     $database->setQuery("SELECT id, title, introtext, created FROM #__content WHERE id = {$item->id}");
  26.     $content = null;
  27.     $database->loadObject($content);
  28.     // filling the array
  29.     $source[$content->id]['title'] = $content->title;
  30.     $source[$content->id]['introtext'] = $content->introtext;
  31.     $source[$content->id]['created'] = strftime("%d/%m/%Y",strtotime($content->created));
  32.     $source[$content->id]['link'] = $mosConfig_live_site . 'index.php?option=com_content&amp;task=view&amp;id='.$content->id.'&amp;Itemid=2';
  33. }
  34. // array is ready. Next step: call the XmlGenerator to do its thing
  35. $xml = new XmlGenerator("latestNews", $source );
  36. echo $xml->createXml();
  37.  
  38. ?>

I hope it works :)

cheers,
bigo

13 Comments so far

  1. FBI May 27th, 2007 11:23 am

    Thanks for the post. I’ll start workin on the action script & let you know how I got on.

    Thx,

    F.B.I

  2. FBI May 27th, 2007 12:44 pm

    there was a parsing error on line 34 so I commented it out.

    /*$source[$content->id][’link’] = $mosConfig_live_site . ‘index.php?option=com_content&task=view&id=’.$content->id’&Itemid=2′;*/

    Not sure what this line is supposed to do, looks like it tries to call up itemid=2, though not sure. Appears to work with the line commented out just fine though.

    I believe the action script would go something like this:

    meuObjXML = new XML();
    meuObjXML.load(”http://www.yoursite.com/xmlgen/xgen-frontPage.php”);
    meuObjXML.ignoreWhite = true;
    meuObjXML.onLoad = function ()
    {
    play ();
    };

    itemId=(item#);

    I think this is right….

  3. bigodines May 27th, 2007 12:49 pm

    would you mind sending the .fla to: bigodines@no spam@joomla.com.br ?

  4. FBI May 27th, 2007 3:06 pm

    well, I haven’t made a flash yet with it. Just created the docs on my server and tried them. I did pull of the script from your site and made a flash of it. Having trouble translating things to English though. I could send it to you for translation….

  5. bigodines May 27th, 2007 3:13 pm

    ok. send me :)

  6. FBI May 27th, 2007 3:28 pm

    ok, sent it. Due to your flash being in Portuguese, some of the functions are in need of translation. I could tell what you achieved, see how you did it (although to recreate it from your language to English has proven a struggle), and am impressed with your skills in action script for not knowing it before the site was created. Good Job!

  7. rawmethodz June 6th, 2007 10:13 am

    This is excellent! Thank you for creating this and helping the joomla community.

  8. ray August 5th, 2007 11:05 am

    Can someone share a fla that loads the front page correctly? I can get the menu to work…but having difficulties with the front page.

  9. Jen W September 11th, 2007 1:51 pm

    could this be used or adapted to be used for any Joomla content, such as specific sections/categories. Would you be able to use this to import any/all Joomla content into a Flash text scroller for instance with the flash nav/menu itmes targeting the scroller instead of the Joomla URL - hence a full flash cms?

    I develop Joomla/Drupal sites, and flash, but am not an expert programmer so feel free to give me a simplistic answer on this one.

    I am looking to see if there is a way to integrate Joomla Community Builder Profiles, a HelpDesk system, and a FAQ system into Flash. In essence to build a one stop interface. But even if I could just start out with getting a handle on how to import Joomla content into flash, that would be a great start.

    I am skilled in the visual end of flash end of things. I can pull out all the stars and banners if need be :) So If you need a hand on at that end with this tutorial I could assist if you could teach some things on the integration/functionality end.

    -Jen

  10. Pitra September 22nd, 2007 6:53 am

    Hi, I’ve tested your class, and it works excellent.

    Just like Jen above, I’d love to see it integrated further with Community Builder. I’m looking forward to tested it further.

    A question, though. How do you display the front end with only my own articles in it? I mean, after I’m logged in, I’d like to see my own articles appear on the front page (in flash mode).

  11. bigodines September 22nd, 2007 2:19 pm

    Pitra, in this case you would need something to grab the user session. I’m now sure how to deal with php sessions in flash but, supose you are already logged in your joomla db (and the session is created) you could add the xmlGen into a component (using index2.php insetead of index.php so you have only the output generated by xmlGen) and use $my->id as a filter in your SQL.

    This should do the trick.

    I’m no Flash expert so I don’t know how you can manage the session in a 100% flash site. If you know, tell me :D

  12. impaler November 25th, 2007 1:24 am

    Wow, nice work people. There is not much I can see around for getting this working elsewhere. I would love to see an example or help on getting a html page from joomla being rendered in flash. Although flash is limited in the html support, you are still able to embed swfs, links and images.
    Being able to have a html and flash site working side by side would be amazing.

  13. salty December 11th, 2007 12:50 pm

    Hi,
    I’ve been trying to create the action script that will load the frontpage content but I can’t seem to get it to work, is there any update on the fla ? I would love to have a look at it and see how this works!
    Sorry to bug you if you haven’t had time for it!

Leave a reply