PLEASE Help Anybody!?@$ flash banner embed

marcin-mark - April 16, 2009 - 11:54

it is 5am and I am desperate to figure this out...

I am trying to embed a .swf banner into the top content of my salamanderskins theme. I am pasting the following code into the ppage.tpl.php

<?php endif; ?>
<div id="middlecontainer">
<table border="0" cellpadding="0" cellspacing="0" id="content">
<tr>
<?php if ($sidebar_left) { ?><td id="sidebar-left">
<?php print $sidebar_left ?>
</td><?php } ?>
<td valign="top">
<?php if ($mission) { ?><div id="mission"><?php print $mission ?></div><?php } ?>
<div id="main">

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="750" height="175">
      <param name="movie" value="sites/all/themes/salamanderskins/images/atm.swf" />
      <param name="quality" value="high" />
<embed src="sites/all/themes/salamanderskins/images/atm.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="748" height="175"></embed>
    </object>

<?php if ($section1count > 0): ?>
<?php if ($breadcrumb): ?><div id="breadcrumb2"><?php print $breadcrumb; ?></div><?php endif; ?>
<?php endif; ?>
<?php if ($content_top):?><div id="content-top"><?php print $content_top; ?></div><?php endif; ?>
<h1 class="title"><?php print $title ?></h1>
<div class="tabs"><?php print $tabs ?></div>
<?php print $help ?>
<?php if ($show_messages) { print $messages; } ?>
<?php print $content; ?>
<?php print $feed_icons; ?>
<?php if ($content_bottom): ?><div id="content-bottom"><?php print $content_bottom; ?></div><?php endif; ?>
</div>
</td>
<?php if ($sidebar_right) { ?><td id="sidebar-right">
<?php print $sidebar_right ?>
</td><?php } ?>
</tr>
</table>
</div>
<?php

all i get is a white box...
please help anyone

Change: <object

jamestamr - April 16, 2009 - 12:15

Change:

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="750" height="175">
      <param name="movie" value="sites/all/themes/salamanderskins/images/atm.swf" />
      <param name="quality" value="high" />
<embed src="sites/all/themes/salamanderskins/images/atm.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="748" height="175"></embed>
    </object>

To:

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="750" height="175">
      <param name="movie" value="/sites/all/themes/salamanderskins/images/atm.swf" />
      <param name="quality" value="high" />
<embed src="/sites/all/themes/salamanderskins/images/atm.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="748" height="175"></embed>
    </object>

James T
Action Medical Research - www.action.org.uk

THANK YOU

marcin-mark - April 16, 2009 - 12:25

i added the back slash /sites/all/themes/salamanderskins/images/atm.swf ... still same problem...

my site is www.atmautos.com

as you can see, evil white box of death

try goto drupalway.com, login

mm167 - April 16, 2009 - 12:42

try goto drupalway.com, login as user demo (psw=demo)

see if that's what u want ..

if yes, I may send u the code ...

We go the drupal way. How about you?
http://www.drupalway.com

I would be more...

ludo1960 - April 16, 2009 - 12:44

yeah, I have filefield, and I

marcin-mark - April 16, 2009 - 12:47

yeah, I have filefield, and I enter multiple images and it doesn't group them... its frustrating, any suggestions?

looks good, I really like the

marcin-mark - April 16, 2009 - 12:46

looks good, I really like the bimmers...

my .swf file is a movie that loops... i wish i could get it to work... but yes, essentially it should be placed in the same fashion...

1. of course, u should

mm167 - April 16, 2009 - 13:05

1. of course, u should already have your myswf.swf ready in the theme folder
2. u also need swfobject.js. do a google earch. download it and put it in the theme folder.
3. assume your theme is named "xxxx"
4. modify your tpl.php as follows ..

// include swfobject.js
global $base_url;
$swfjs = $base_url . '/' . drupal_get_path('theme','xxxx') . '/swfobject.js';
$x = '<script type="text/javascript" src="'. $swfjs .'" ></script>';
print $x;


// set up the swf div
$swf_file = $base_url . '/' . drupal_get_path('theme','xxxx') . '/myswf.swf';
$x = '<div id="myswf"></div>'
. '<script type="text/javascript">'
. 'var s1 = new SWFObject("'.$swf_file.'","myswf","800","80","9");'
. 's1.addParam("allowScriptAccess","sameDomain");'
. 's1.addParam("wmode","transparent");'
. 's1.write("myswf");'
. "</script>";

.....

// print out swf div at right position
print $x;

** xxxx is your theme name

--------------------------------------
we go the drupalway, how about u?

drupalway.com

We go the drupal way. How about you?
http://www.drupalway.com

THANK YOU

marcin-mark - April 16, 2009 - 13:16

Still not working for some reason... am I doing something wrong?

<?php endif; ?>
<div id="middlecontainer">
<table border="0" cellpadding="0" cellspacing="0" id="content">
<tr>
<?php if ($sidebar_left) { ?><td id="sidebar-left">
<?php print $sidebar_left ?>
</td><?php } ?>
<td valign="top">
<?php if ($mission) { ?><div id="mission"><?php print $mission ?></div><?php } ?>
<div id="main">

// include swfobject.js
global $base_url;
$swfjs = $base_url . '/' . drupal_get_path('theme','salamanderskins') . '/swfobject.js';
$x = '<script type="text/javascript" src="'. $swfjs .'" ></script>';
print $x;


// set up the swf div
$swf_file = $base_url . '/' . drupal_get_path('theme','salamanderskins') . '/atm.swf';
$x = '<div id="atm"></div>'
. '<script type="text/javascript">'
. 'var s1 = new SWFObject("'.$swf_file.'","atm","800","80","9");'
. 's1.addParam("allowScriptAccess","sameDomain");'
. 's1.addParam("wmode","transparent");'
. 's1.write("atm");'
. "</script>";

.....

// print out swf div at right position
print $x;
<?php if ($section1count > 0): ?>
<?php if ($breadcrumb): ?><div id="breadcrumb2"><?php print $breadcrumb; ?></div><?php endif; ?>
<?php endif; ?>
<?php if ($content_top):?><div id="content-top"><?php print $content_top; ?></div><?php endif; ?>
<h1 class="title"><?php print $title ?></h1>
<div class="tabs"><?php print $tabs ?></div>
<?php print $help ?>
<?php if ($show_messages) { print $messages; } ?>
<?php print $content; ?>
<?php print $feed_icons; ?>
<?php if ($content_bottom): ?><div id="content-bottom"><?php print $content_bottom; ?></div><?php endif; ?>
</div>
</td>
<?php if ($sidebar_right) { ?><td id="sidebar-right">
<?php print $sidebar_right ?>
</td><?php } ?>
</tr>
</table>
</div>

1. u have forgotten to add <

mm167 - April 16, 2009 - 13:31

1. u have forgotten to add < ? p h p and ? > for my codes

2. those '.....' is not need

3. "print $x" should be added in the right position..where u want to show the swf.

We go the drupal way. How about you?
http://www.drupalway.com

Now I get this: Parse error:

marcin-mark - April 16, 2009 - 16:34

Now I get this:
Parse error: syntax error, unexpected T_VARIABLE in /home3/atmautos/public_html/sites/all/themes/salamanderskins/page.tpl.php on line 150

Is this right? // include

marcin-mark - April 16, 2009 - 16:54

Is this right?

// include swfobject.js
<?php global $base_url; ?>
<?php $swfjs = $base_url . '/' . drupal_get_path('theme','salamanderskins') . '/swfobject.js'; ?>
<?php $x = '<script type="text/javascript" src="'. $swfjs .'" ></script>'; ?>
<?php print $x ?>
// set up the swf div
<?php $swf_file = $base_url . '/' . drupal_get_path('theme','salamanderskins') . '/atm.swf';
$x = '<div id="atm"></div>' ?>

. '<script type="text/javascript">'
. 'var s1 = new SWFObject("'.$swf_file.'","atm","800","80","9");'
. 's1.addParam("allowScriptAccess","sameDomain");'
. 's1.addParam("wmode","transparent");'
. 's1.write("atm");'
. "</script>";
// print out swf div at right position
<?php print $x; ?>

no .."$x = .." is a long

mm167 - April 17, 2009 - 01:27

no .."$x = .." is a long line. try this ..

<?php
$swf_file
= $base_url . '/' . drupal_get_path('theme','salamanderskins') . '/atm.swf';
$x = '<div id="atm"></div>'
. '<script type="text/javascript">'
. 'var s1 = new SWFObject("'.$swf_file.'","atm","800","80","9");'
. 's1.addParam("allowScriptAccess","sameDomain");'
. 's1.addParam("wmode","transparent");'
. 's1.write("atm");'
. "</script>";
?>

We go the drupal way. How about you?
http://www.drupalway.com

THANK YOU! Hooray, it

marcin-mark - April 17, 2009 - 02:11

THANK YOU!

Hooray, it works!

Hi guys, I did the same but i

Anandyrh - April 17, 2009 - 04:39

Hi guys,
I did the same but i get this error // include swfobject.js // set up the swf div

How to fix this ?

Regards,
AnAnD

about the "// error" .. there

mm167 - April 17, 2009 - 05:32

about the "// error" ..
there are just comments...remove it in case of any error ..

We go the drupal way. How about you?
http://www.drupalway.com

This my code, is anything

Anandyrh - April 17, 2009 - 04:52

This my code, is anything wrong in this?

// include swfobject.js
<?php global $base_url; ?>
<?php $swfjs = $base_url . '/' . drupal_get_path('theme','acquia_marina') . '/swfobject.js'; ?>
<?php $x = '<script type="text/javascript" src="'. $swfjs .'" ></script>'; ?>
<?php print $x ?>
// set up the swf div
<?php
$swf_file
= $base_url . '/' . drupal_get_path('theme','acquia_marina') . '/my_banner.swf';
$x = '<div id="my_banner"></div>'
. '<script type="text/javascript">'
. 'var s1 = new SWFObject("'.$swf_file.'","my_banner","953","256","7");'
. 's1.addParam("allowScriptAccess","sameDomain");'
. 's1.addParam("wmode","transparent");'
. 's1.write("my_banner");'
. "</script>";
?>

Regards,
AnAnD

wo..u need 2 print $x, 1st

mm167 - April 17, 2009 - 05:33

about the "// error" ..
there are just comments...remove it in case of any error ..

wo..u need two print $x,
1st print out the "include swfobject.js"
2nd print out the < d i v id="my_banner"> for your logo

u have to find a right position to print the < d i v id="my_banner"> according to your need.

BTW, it is marcin's post. in case u still have question, pls open a new post.

We go the drupal way. How about you?
http://www.drupalway.com

Thank you!

Anandyrh - April 17, 2009 - 05:46

Thank you!

Regards,
AnAnD

This is how I use flash

Jay Matwichuk - April 17, 2009 - 06:01

This is how I use flash banners in my templates.

1) install swftools module
2) install swfobject2 module (part of swftools - requires that swfobject.js be downloaded and placed in 'shared/swfobject2' inside the swftools module folder )
3) go to swftools settings, and set rendering to be done by swfobject2
4) create a file called template.php in the theme folder
5) use this code inside template.php

<?php
   
function qqeigo_preprocess(&$vars, $hook)
{
    switch(
$hook)
    {
        case
'page' :
           
$vars['flash_banner'] = swf
           
(
               
'path/to/flash/file.swf',
                array
                (
                   
'params' => array
                    (
                       
'width' => '228',
                       
'height' => '618',
                       
'wmode' => 'transparent',
                    ),
                   
'othervars' => array
                    (
                        
'html_alt' => '<img src="' base_path() . drupal_get_path('theme', 'theme_name') . '/images/no_flash.png" alt="Replacement image used when flash does not load for whatever reason" />',
                    ),
                )
            );
            break;
    }
}
?>

6) In page.tpl.php, you can then output the flash file using the variable $flash_banner:

<div id="flash_banner"><?php print $flash_banner; ?></div>

Why this method is good:

1) It uses swfobject which is cross browser compatible, and produces valid markup
2) It keeps a separation between function (template.php) and design (page.tpl.php)
3) It follows drupal coding standards
4) It's clean, easy to read code
5) It doesn't take a lot of code to do it, making the code easier to read
6) It provides a replacement image for people who can't view flash for whatever reason
7) It provides replacement text for people who who also have images turned off (i.e. blind people using screen readers, or some people using cell phones)

This worked for me! I have

Anandyrh - April 17, 2009 - 09:58

This worked for me!

I have installed SWFtools module

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="953" height="256" id="my_banner" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="my_banner.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#666666" /><embed src="my_banner.swf" quality="high" bgcolor="#666666" width="953" height="256" name="my_banner" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>

Regards,
AnAnD

It's come to my attention

Jay Matwichuk - October 24, 2009 - 11:47

It's come to my attention that in my example code above, I used the name of my theme, meaning that the code won't work for others who are trying to use it. You need to change:

function qqeigo_preprocess(&$vars, $hook)

to:

function phptemplate_preprocess(&$vars, $hook)

or else:

function THEMENAME_preprocess(&$vars, $hook)
where you replace 'THEMENAME' with the name of your theme.

 
 

Drupal is a registered trademark of Dries Buytaert.