Forums / Developer / Flash Banner with dynamic fields

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.

eZ debug

Timing: Jan 18 2025 18:17:43
Script start
Timing: Jan 18 2025 18:17:43
Module start 'content'
Timing: Jan 18 2025 18:17:44
Module end 'content'
Timing: Jan 18 2025 18:17:44
Script end

Main resources:

Total runtime1.1368 sec
Peak memory usage4,096.0000 KB
Database Queries194

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0064 587.7188180.8281
Module start 'content' 0.00641.0045 768.5469567.1250
Module end 'content' 1.01080.1259 1,335.6719336.7422
Script end 1.1367  1,672.4141 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00460.4014210.0002
Check MTime0.00180.1625210.0001
Mysql Total
Database connection0.00060.052210.0006
Mysqli_queries1.062793.48651940.0055
Looping result0.00200.17491920.0000
Template Total1.106597.320.5532
Template load0.00240.208220.0012
Template processing1.104197.126420.5520
Template load and register function0.00020.021610.0002
states
state_id_array0.00120.104110.0012
state_identifier_array0.00110.097620.0006
Override
Cache load0.00180.1572360.0000
Sytem overhead
Fetch class attribute can translate value0.00160.143930.0005
Fetch class attribute name0.00180.157940.0004
XML
Image XML parsing0.00290.253230.0010
class_abstraction
Instantiating content class attribute0.00000.000740.0000
General
dbfile0.00370.3267270.0001
String conversion0.00000.000630.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
10content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
7content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 24
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs