SOLVED - help with: CGfeedMaker, News - outputting xml structur for Flash

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
madsny
Forum Members
Forum Members
Posts: 31
Joined: Mon Jul 14, 2008 2:46 pm

SOLVED - help with: CGfeedMaker, News - outputting xml structur for Flash

Post by madsny »

SOLVED
Hi

My Final goal is to use CMSMS as the core cms for my flash site, i'll post everything i learn on the way for others to get inspired as well.

XML exporting issue:
Flash works with xml and CGfeedMaker makes a perfect job exporting the news elements as RSS, but for flash im looking for a solution to structure all news elements into theire resepctive categories like this:


.... news dump for category 1


.... news dump for category 2

etc.

Im fairly new to CMSMS and not that strong in PHP, but one of the ideas i've been trying out is to loop the categories in a similair way as the items are done, i just can't seem to find the tricker for categories.
   {foreach from=$item item='?????'}
   .....dummy. Data....
   {/foreach}

Any suggestions
// Mads ny
Last edited by madsny on Sun Aug 23, 2009 10:54 pm, edited 1 time in total.
JeremyBASS

Re: help with: CGfeedMaker, News - outputting xml structur for Flash

Post by JeremyBASS »

you know you can just make a template in the news mod... and formate that is XML... just a tip... Cheers
Jeremy
madsny
Forum Members
Forum Members
Posts: 31
Joined: Mon Jul 14, 2008 2:46 pm

Re: help with: CGfeedMaker, News - outputting xml structur for Flash

Post by madsny »

That's not a bad idea, and then showing the page in a "empty" template in a hidden archive..

i played a bit around with it, it seems okay but i still can figure out how to make a routine running through all the categories so i can wrap these inside a few tags, frustrating since it must be so simple.

From looking through the other templates inside the content > news module i came up with this as a plausible solution.

Code: Select all

{foreach from=$cats item=node}
	<div>
		<a href="{$node.url}">{$node.news_category_name}</a> ({$node.count})
	</div>
{/foreach}
but it does not work, like the system don't compute the $cats... should i use another variable caller id ?.. (i've place my template under "summery templates", don't know if that have any effect for the init of the php variables )

thanks :)
Mads 
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: help with: CGfeedMaker, News - outputting xml structur for Flash

Post by calguy1000 »

it's not hard,  you just gotta do it with multiple calls to News.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
madsny
Forum Members
Forum Members
Posts: 31
Joined: Mon Jul 14, 2008 2:46 pm

Re: help with: CGfeedMaker, News - outputting xml structur for Flash

Post by madsny »

thanks.

im sure it's not hard, but since this is my first time using the system plus im more of a flash dev, then it all seem's a bit mystifying to me hehe, thou i must admit that the CMSMS system seems pretty cleaver and 100 times better than the last time i used it (2 years ago)

is there a documentation of all the template variables for the news and other modules, the only way i've been able to retrieve some valid information is by trail and error with {$.....|print_r} call's pretty tedious work.

as far as i under stand all entries are storage in $items, im not sure what $node is good for, i hoped i would contain the amount of categories and if luckely their names, but nope (im referring to $node->depth).
are there any other template variables i don't know about ?.

I have a theoretical idea, it goes like this:
run through all $items, storage the first items category name in a variable, check if the items category name have changed from the variable, if so then create the category tags, if not keep plotting them entries out... :).

hmmm that's not a bad idea, but i just can't help thinking that there's a better way to do this... anyway i'll have a go on it tomorrow and se what happens...
madsny
Forum Members
Forum Members
Posts: 31
Joined: Mon Jul 14, 2008 2:46 pm

Re: help with: CGfeedMaker, News - outputting xml structur for Flash

Post by madsny »

SOLVED :)
HA HAAAA im so happy, 5 min before bedtime and i finally got it working, the logic i mean ;).
so for anyone else who want to turn the news feed into an xml output for ex. flash to eat, here's one way of ordering your xml based on the categories (one level only im afraid)

Code: Select all

{assign var='tc' value=$items[0]->category}
<cat>
{foreach from=$items item=entry}
	{if $entry->category eq $tc}
		{$tc}
	{else}
		</cat>
		<cat>
		{assign var='tc' value=$entry->category}
	{$entry->category}
	{/if}
{/foreach}
</cat>
and my output is ;)..

Code: Select all

<cat>
General
</cat>
<cat>
arselectronica
</cat>
<cat>
topstory
topstory
topstory
</cat>

super easy fix loving it.
but i must admit that the documentation and API's for the different modules are very hard to find, so for anyone like me who just love to jump into it without study too much, i'll recommend having a look at this documentation over the smarty API, as i under stand it's the syntaxes for writing php in the templates.... right ??

http://www.smarty.net/manual/en/languag ... ion.assign

Thanks for the help and suggestions :). (next stop making an xml exporter for the album to flash :D)
madsny
Forum Members
Forum Members
Posts: 31
Joined: Mon Jul 14, 2008 2:46 pm

Re: SOLVED - help with: CGfeedMaker, News - outputting xml structur for Flash

Post by madsny »

Okay, just want to post what i've learned so everyone else can have a ball with CMSMS and Flash.
Before we start i have to strech that i've just made this work for myself, i might have missed a step or two in my explanation but it should inspire you on how to make the news module print it's data as xml for flash :)

To make the news module print out as xml there's a few things we need to fix first.

01 - make our own news summary template
02 - setup ud a normal page for our xml data
03 - make a clean page template (nothing in it but xml content)
04 - remove some comments in a php file
05 - some Flash code


01.
first of, the news Summery template, goto content > news > (tab) summery templates
make a new template and past in this code, in short it runs through all the news entries and placing them within theire own category tags for easy access and sorting within flash.

Code: Select all

{assign var='tc' value=$items[0]->category}
<cat>
{foreach from=$items item=entry}
	{if $entry->category eq $tc}
		<postdate><![CDATA[{$entry->postdate|cms_date_format}]]></postdate>
		<pageUrl><![CDATA[{$entry->moreurl}]]></pageUrl>
		<title><![CDATA[{$entry->title|cms_escape}]]></title>
		<catName><![CDATA[{$entry->category}]]></catName>
		<auther><![CDATA[{$entry->author}]]></auther>
		<summery><![CDATA[{eval var=$entry->summary}]]></summery>
		<content><![CDATA[{eval var=$entry->content}]]></content>
		<extra><![CDATA[{eval var=$entry->extra}]]></extra>
	{else}
</cat>
<cat>
		{assign var='tc' value=$entry->category}
		<postdate><![CDATA[{$entry->postdate|cms_date_format}]]></postdate>
		<pageUrl><![CDATA[{$entry->moreurl}]]></pageUrl>
		<title><![CDATA[{$entry->title|cms_escape}]]></title>
		<catName><![CDATA[{$entry->category}]]></catName>
		<auther><![CDATA[{$entry->author}]]></auther>
		<summery><![CDATA[{eval var=$entry->summary}]]></summery>
		<content><![CDATA[{eval var=$entry->content}]]></content>
		<extra><![CDATA[{eval var=$entry->extra}]]></extra>
	{/if}
{/foreach}
</cat>
it's not pretty but it works :D



02.
let's create a new page which will output our xml formatted news elements.
goto content add new page where ever you like, call it whatever you like
before we write the code to view the news elements, then turn off the WYSIWYG, otherwise we'll might end up with a few html tags in our xml feed, now type this line.

{cms_module module='news' number='5' summarytemplate='NAME-OF-YOUR-NEWS-SUMMERY-TEMPLATE'}

(well im not sure about the number='5' if you get problem then mingle a bit with that hehe)
okay now you should be able to view the site, click on the page you created for news and you should see the html page plus all your news elements in one big mess



03.
Clean page template to remove all html code other than the xml news feed.
goto Layout > templates
Create a new template and type this in

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xmldata>
{content}
</xmldata>
this will create a tottaly blank page and and inserting whatever content we feed it through the pages's (our home made xml news feed), but to make this work we myst go back to our page in "content" and assign our new template to that page, revisit the page we created earlier goto to the options tab and change the tempate to what ever you named your template.

04
if you view your page live again you should see the news feed's only without any html stuff, try view source to make sure the data is all XML based data only.
well it's properly not, at the top and bottom you'll properly notice some commended text, to remove this we'll have to edit the PHP file which build the news feed, don't worry it's VERY simple.
hook up your FTP client and goto this folder:
/modules/news

download and open this file in ex. notepad
action.default.php

scroll down on the page till you find this:

Code: Select all

echo "<!-- Displaying News Module -->\n";
echo "<!-- News Categories: '".(isset($params['category'])?$params['category']:'')."' -->\n";
delete thoes two lines, save the file and upload and overwrite the php file in /modules/news
That's it




05.
i use this code in flash to load my XML file (AS2)

Code: Select all

function loadXML(success) {
	if(success) {
		
		txt.htmlText = unescape( this.childNodes[0].childNodes[6].childNodes );

	}else{
		trace("Error on loading the XML file");
	}
}
_root.xmlData = new XML();
_root.xmlData.ignoreWhite = true;
_root.xmlData.onLoad = loadXML;
_root.xmlData.load("LINK-TO-PAGE-THAT-PRINTS-YOUR-XML-NEWSFEED");
to get the right link, just view the page in your browser, copy past the link in flash :)
(ps. in the AS code im outputting the xml data to a text object called "txt" )


I hope this would help anyone who's interessted in using CMSMS as a CMS for their flash projects.
Kind regards

Mads ny
www.madeofdots.com ;)
Last edited by madsny on Mon Aug 24, 2009 8:43 pm, edited 1 time in total.
JeremyBASS

Re: SOLVED - help with: CGfeedMaker, News - outputting xml structur for Flash

Post by JeremyBASS »

Glad to see you got it going... Good write up.  Want to know something funny... that pic on http://www.navida.dk/ ... the one of the man and boy on the shoulders... I have an ad for a hospital here with the same ... I mean very same image... :D just funny ... Cheers
Jeremy
madsny
Forum Members
Forum Members
Posts: 31
Joined: Mon Jul 14, 2008 2:46 pm

Re: SOLVED - help with: CGfeedMaker, News - outputting xml structur for Flash

Post by madsny »

HAHAHA PRICELESS i love Stock photo's it's like bringing your family with you everywhere hehe.
but seriously it's going to be an issue in the future with all this mashUp design, meaning grapping pre made elements from here and there, still there are a few good stock photo services out there where you'll get kind of "unique" photos, but it cost hehe.

anyway thanks for the help it guided me in the right direction, now im going do the same with the album, hope it'll go smooth, i must admit when you first get into the smarty code structure CMSMS is really nice and flexible to work with :)
JeremyBASS

Re: SOLVED - help with: CGfeedMaker, News - outputting xml structur for Flash

Post by JeremyBASS »

Yeah the way of the world ... so since I'm feeling happy dappy today and karma feeds the sole... here is a sample of a working xml output for albums... little something to get you started..

Code: Select all


<rotator>

	<rotatorSettings

delayTime = "5"
randomTrans = "true"
infoTxtColor = "FFFFFF"
infoBtnBg = "DDD2B6"
controlsTxtColor = "FFFFFF"
controlsBg = "DDD2B6"
InfoBoxBg = "000000"
infoBoxAlpha = "60"
preloaderAlpha = "100"
preloaderColor = "FFFFFF"
mainBgColor = "DDD2B6"
infoOpen = "true"

    />
{foreach from=$pictures item=picturesrow}
	    {foreach from=$picturesrow item=onepicture}
<image>
	    <imgLoc>{$onepicture->thumbnail}</imgLoc>
		<transition>4</transition>
		<title><![CDATA[<b>{$onepicture->name|escape:'html'}</b>]]></title>
		<textBox><![CDATA[{$onepicture->comment|escape:'html'}]]></textBox>
		<txtBoxBgHeight>75</txtBoxBgHeight>
</image>
{/foreach}
	{/foreach}
</rotator>
	
the working modle is here... http://www.calamshriners.com/testing/... the on on the side... thou I'm ditching it for the on in the content area... Anyways Hope that helps... Cheers
Jeremy
Last edited by JeremyBASS on Mon Aug 24, 2009 9:30 pm, edited 1 time in total.
madsny
Forum Members
Forum Members
Posts: 31
Joined: Mon Jul 14, 2008 2:46 pm

Re: SOLVED - help with: CGfeedMaker, News - outputting xml structur for Flash

Post by madsny »

hehe, you seem quite happy there :) that super nice, inspiring i might add hehe.
Well i seemed to have cracked the Album aswell, damn i have found myself a new frind mr. CMSMS
here we go...

Album xml output for flash

01 - the album to XML template
02 - page setup
03 - flash


01.
Album template for exporting all images from the album to as an XML feed in the following structure

... images

etc. etc.

first you need to install the Album module goto Modul manager > (tab) available modules    and find Album
when installed, goto Content > photo albums
create a few albums and upload or assign some images to each of them.
no goto to the Templates Tab, create a new template and past the following template code and save

Code: Select all

{assign var='albumNum' value=0}
{foreach from=$albums item=album2}
	{assign var='albumNum' value=$albumNum+1}
	{capture assign='photos'} 
		{cms_module module='album' albums=$albumNum}
	{/capture} 

<album>
{foreach from=$pictures item=picturesrow}
{foreach from=$picturesrow item=onepicture}
<image>
	    <imgLoc>{$onepicture->thumbnail}</imgLoc>
	    <title><![CDATA[<b>{$onepicture->name|escape:'html'}</b>]]></title>
            <textBox><![CDATA[{$onepicture->comment|escape:'html'}]]></textBox>
</image>
{/foreach}
{/foreach}
</album>
{/foreach}
Perfect now we have a template which should run through all first level albums and build a nice xml structure for our flash program


02.
creating the output page
as previous with the news page, create a new page under content, add this line

Code: Select all

{cms_module module='album'}
goto options and be sure to select a template which is stripped for html and set up the base of xml file.



03.
in flash you can load your xml data in like this.

Code: Select all

function loadXML(success) {
	if(success) {
		
		trace( unescape(    this.childNodes[0].childNodes[0].childNodes[1].childNodes[0].firstChild )  );

	}else{
		trace("Error on loading the XML file");
	}
}
_root.xmlData = new XML();
_root.xmlData.ignoreWhite = true;
_root.xmlData.onLoad = loadXML;
_root.xmlData.load("PATH-FOR-THE-PAGE-CREATING-THE-XMLOUTPUT");
from here's you'll just have to make a preloader routine to preload all images and do what ever you like (check actionscript.org for help on this topic)

Next up:
- xml Export to Flash for the calender
- xml Export to flash of some blog system
- xml Export to flash of the menu structure
- xml Export to flash of full pages, ex. if the call have a special attribute

(but this will have to be another time)

Voila, enjoy.
if anyone got similar trix and tips please post them :)
madsny
Forum Members
Forum Members
Posts: 31
Joined: Mon Jul 14, 2008 2:46 pm

Re: SOLVED - help with: CGfeedMaker, News - outputting xml structur for Flash

Post by madsny »

Sad news, the Album to xml template i've postet here does not do the job correctly, i'll post a new one if i find the solution
//Masd
madsny
Forum Members
Forum Members
Posts: 31
Joined: Mon Jul 14, 2008 2:46 pm

Re: SOLVED - help with: CGfeedMaker, News - outputting xml structur for Flash

Post by madsny »

for anyone who's interested in making their own flash photoAlbum or wahtever, i've found another way of porting the photoalbum to a valid XML feed.



Just to keep any interessted updated, i solved the problem.

Here's how you post all photo links into an xml within their respective categories (good for flash).

you'll need installed:
CGfeedMaker
photo album

CGfeedMaker template:
this is the template im using for the feedmaker.

Code: Select all

<?xml version="1.0"?>
<rss version="2.0">
  <channel>
 
{assign var='albumNum' value=-1}
  
{capture assign='albumsfff'}
	{cms_module module='album'}
{/capture}   

{foreach from=$albums item='entry'}
	<cat>
	{assign var='albumNum' value=$albumNum+1}
	
    {capture assign='photos'}
      {cms_module module='album' action='recently_updated' albums=$albums[$albumNum]->id number='15'}
    {/capture}   

    {foreach from=$pictures item='entry'}
    	<item>
	    	<title>{$entry->name}</title>
    		<img>{$entry->picture}</img>
    		<imgthumb>{$entry->thumbnail}</imgthumb>
    	</item>
    {/foreach}
    
    
    </cat>
    {/foreach}
  </channel>
</rss>

PAGE:
Then create a new page and place this link, with a ref. to your template
{CGFeedMaker action='rsslink' feed='YOUR TEMPLATE NAME'}

if you then visit this page you'll see an rss link, clicking on it and you'll get the right url to place into ex. Flash to fetch all you photos :D..

you'll properly have to tweek the code a bit here and there to meet your demands, but it workes nicely

Enjoy
Post Reply

Return to “Modules/Add-Ons”