I'm using drupal 7 and marinelli theme, I'm trying to put an .swf file for my site logo is this possible for ver.7 or not? Thanks!

Comments

d_l’s picture

This is untested with Marinelli but I have used a similar approach with another theme.

Start by downloading swfobject and create an "ext" folder in marinelli theme to drop in swfobject files.

http://code.google.com/p/swfobject/wiki/documentation

Then go to edit marinelli/templates/html.tpl.php to create link to marinelli/ext/swfobject/swfobject.js.

Put the script links below just before the line containing </head> in html.tpl.php.

You should then be able to use swfobject.js to write your logo.swf file into div name "logo-container" in page.tpl.php.

The body of code in html.tpl.php should look like this (I've referred to "test.swf" in the swfobject distribution as the test logo but you can add your own logo.swf with different arguments).

echo '<script type="text/javascript" src="http://localhost:8080/drupal-7.0/sites/all/themes/marinelli/ext/swfobject/swfobject.js">';
echo '</script>';
echo '<script type="text/javascript">';
echo 'swfobject.embedSWF("http://localhost:8080/drupal-7.0/sites/all/themes/marinelli/ext/swfobject/test.swf", "logo-container", "300", "120", "10.0.0", "http://localhost:8080/drupal-7.0/sites/all/themes/marinelli/ext/swfobject/expressInstall.swf");';
echo '</script>';

You might have to tweak the logo-container div css to allow logo.swf to be written in there.

d_l’s picture

This code seems to work in Marinelli

echo '<script type="text/javascript" src="http://localhost:8080/drupal-7.0/sites/all/themes/marinelli/ext/swfobject/swfobject.js">';
echo '</script>';
echo '<script type="text/javascript">';
echo 'swfobject.embedSWF("http://localhost:8080/drupal-7.0/sites/all/themes/marinelli/ext/swfobject/test.swf", "logo-container", "300", "120", "10", "http://localhost:8080/drupal-7.0/sites/all/themes/marinelli/ext/swfobject/expressInstall.swf");';
echo '</script>';

It could be embedded as html (instead of php as above) .. but you might wish to tweak it to use php include to switch different blocks of swfobject code into <head> .. </head> section for different logos.

d_l’s picture

typo error corrected below in next post ..

d_l’s picture

// edit html.tpl.php file in head section
// relative drupal path to marinelli theme and /ext/swfobject/*.* files

$path = "./" . drupal_get_path('theme', 'marinelli') . "/ext/swfobject/";
echo '<script type="text/javascript" src="';
echo $path;
echo 'swfobject.js"></script>';
echo '<script type="text/javascript">swfobject.embedSWF("';
echo $path;
echo 'test.swf", "logo-container", "300", "120", "10.0.0", "';
echo $path;
echo 'expressInstall.swf");</script>';
d_l’s picture

One further refinement.

If the client browser does not have the required version of flash player installed swfobject provides for alternative content to be displayed with "get Adobe Flash Player" logo with a link to http://www.adobe.com/go/getflashplayer.

This requires some code to be included in the target container .. in this case "logo-container" in page.tpl.php.

So you can

either

(a) insert no alternative text code and instead create a custom logo.png (120px x 120px) which displays when the flash player is not installed.

or

(b) insert the alternative text code and comment out the php code which writes logo.png into the container.

This is how the div logo-container has to be edited ..

<?php if($logo): ?>
<div id="logo-container">
<?php
// this is the alternative content if Adobe flash player is not installed
echo '<p>Alternative content if flash player is not installed</p>';
echo '<p><a href="http://www.adobe.com/go/getflashplayer">';
echo '<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>';
?>
<?php 
// comment out print logo.png or uncomment if logo.png is to be displayed
// print $imagelogo; 
?>
</div>

You can test this by setting the swfobject argument defining flash version to be higher than your installed flash player version .. e.g. "12" .. and on refresh the alternative text or alternative logo.png will be displayed.

negatifo’s picture

Thanks Man I got it working. (beer) :)

Boze’s picture

I have a problem. I don't have html.tpl.php in my theme ( Corolla). Where should I put this code? Can I put it in page.tpl.php instead?

Thanks