Flash Banner with dynamic fields

Author Message

Pierre SCALFATI

Wednesday 15 July 2009 8:35:27 am

Hello,

I created a flash banner which displays text in a flash animation. The text is loaded from .txt files to the various dynamic text zones of the animation. Everything work fine when you are out of an EZPUBLISH context. But once you insert your flash banner in the pagelayout.tpl, the text is not loaded and stays static with its default values.

Here is the code I put in my flash


loadVariables("text1.txt", this);

In my text1.txt I have a single lign containing this :

texte1=My Beautiful Text

The swf file and the txt files are in the same directory (my swf is executed and displayed without any problem except for the variables which doesn't load). I don't know how it is loaded by EZP. Is it going to put it in some storage folder and if so, how to avoid this and make my txt files being read whatever folder they are in (I tried in my Flash code to do a loadVariables("/myfolder/text1.txt", this) but this doesn't work too.

Any ideas about how to make it work ?

Many thanks.

Patrick Kaiser

Wednesday 15 July 2009 10:10:04 am

Hi,

I dont know where do you did put your text-file exactly, but you have two options:

1) This is most probably not the best option, but will work:
Place the text file somewhere on your server where it gets served by apache (Be aware of the apache rewrite rules!). Try it by calling the text-file directly in your browser, like http://yourezhost/yourtextfile.txt
make sure to adjust your rewrite rules

RewriteRule ^/yourtextfile\.txt - [L]

2) Adjust the flash to use flashVars to pass the filename to the textfile. add a file attribute to the content class of the page-type where you want to show the flash (or create a new one), create a object and upload the textfile. use something like this to dynamicly insert the path to the textfile (example with swfobject to embed the flash):

{def 
$node_with_textfile=fetch( 'content', 'node', hash( 'node_id', PUT_THE_NODEID_HERE))}
$textfile_path = $node_with_textfile.data_map.YOUR_TEXTFILE_ATTRIBUTE.content.filepath|ezroot
}

<script type="text/javascript" src="/path/to/swfobject.js"></script>
<div id="flash-div">
	<p class="get-flash"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this clip.</p>
</div>

<script type="text/javascript">
	{literal}
	var flashvars					= {};
	flashvars.textfile_path			= {/literal}{$textfile_path}{literal};	
	var params					= {};	
	var attributes					= {};
	swfobject.embedSWF( "/path/to/your.swf", 'flash-div', "100%", "100%", "9.0.60", "/path/to/expressInstall.swf", flashvars, params, attributes);
{/literal}
</script>


Best regards,

Patrick

Pierre SCALFATI

Wednesday 22 July 2009 9:07:19 am

Hi Patrick, Hi Everybody,

After having read your reply, Patrick, I must recognize that it seemed to me a bit difficult to apply the solution you were suggesting. But it led me, somehow, to the right path.

So here is what I did (but probably there are other, maybe proper, ways to do it):

- First, of course, in my Flash Animation I created my text fields declaring them as Dynamic.

- Then I modified my template to put the following code :

<!-- put the following line for accessing your content in EZPUBLISH -->
{def $flash_banners    = fetch('content', 'list',hash('parent_node_id', 107, 'depth', 0
		                                      )
			       )
}
<!-- then insert your flash object with flashvars params. Here, I read 4 labels stored in EZPUBLISH contents -->

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/...sh/swflash.cab#version=6,0,0,0" width="900" height="150" id="Banner" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="http://mysite/myfolder/flash/bandeau.swf" />
<param name="FlashVars" value="texte1={$flash_banners[0].data_map.texte1.content}&texte2={$flash_banners[0].data_map.texte2.content}&texte3={$flash_banners[0].data_map.texte3.content}&texte4={$flash_banners[0].data_map.texte4.content}">
<param name="quality" value="low" />
<param name="bgcolor" value="#ffffff" />
<embed src="http://mysite/myfolder/flash/bandeau.swf" FlashVars="texte1={$flash_banners[0].data_map.texte1.content}&texte2={$flash_banners[0].data_map.texte2.content}&texte3={$flash_banners[0].data_map.texte3.content}&texte4={$flash_banners[0].data_map.texte4.content}" quality="high" bgcolor="#ffffff" width="900" height="150" name="PlanPenfeld" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>

Then I did something special in order to not display my "Flash Banner" folder which I created in ezpublish treemenu. For that I added to my class "Folder" a checkbox field named "Display in top Menu" and then in my top_menu.tpl override, I filtered the fetch function which is used to display the different parent folders of my site in the topmenu as follows :


{def $root_node=fetch( 'content', 'node', hash( 'node_id', $indexpage ) )
         $top_menu_items=fetch( 'content', 'list', hash( 'parent_node_id', $root_node.node_id,
                                                          'sort_by', $root_node.sort_array,
                                                          'class_filter_type', 'include',
                                                          'class_filter_array', ezini( 'MenuContentSettings', 'TopIdentifierList', 'menu.ini' ) 
,
														  'attribute_filter', array(
        array( 'folder/visible_in_menu', '=', 1 ))

) )
 

In the above code, I just added the following to the default fetch function which is delivered by default with ezpublish:

'attribute_filter', array(
        array( 'folder/visible_in_menu', '=', 1 ))

NB : don't forget for the different parent folders that you want to display in the top menu of your front-office site to fix the value of the checkbox "Display in top menu" to true and to set to false this value for the folder containing the Flash banner content.

Hope it will help.

Best regards.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.