...

View Full Version : PHP in the <embed> tag.....is it possible?



jpmad4it
03-27-2007, 04:56 PM
Hi everyone,

I have a flash banner rotator that runs using PHP at the backend. The way in which the flash banner is called into the script is by using the following PHP:

<? php include("http://www.mysite.com/banners"); ?>

I have also used this in other ways such as:

<?php $file = file_get_contents("http://www.mysite/banners"); ?>

I am struggling to incorporate this into the <object> tag. Is there a way in which I can do this? Can I somehow get this to work in the <param name="movie"> tag? Or is there some other method that I can use?

I should also mention that the file I am working with is a 'tpl' file. I do not think that these support PHP, but I may be wrong.

Any help would be great as I am really struggling with this one.

Kind regards,
Jp

aedrin
03-27-2007, 05:28 PM
You can put PHP wherever in a file. It does not care where it is.

And yes, the server would have to be set up to use PHP on .tpl files, otherwise it won't work.



<param name="movie" value="<?php echo $movieName; ?>">


This would work fine.

jpmad4it
03-27-2007, 05:38 PM
You can put PHP wherever in a file. It does not care where it is.

And yes, the server would have to be set up to use PHP on .tpl files, otherwise it won't work.



<param name="movie" value="<?php echo $movieName; ?>">


This would work fine.

The thing is that its a random Flash banner rotator, so the movie name always changes on the refresh of the page. So a single/static movie name won't work. Unless I have misunderstood your code......could you explain it for me i'm a bit numb when it comes to PHP :o

rafiki
03-27-2007, 06:11 PM
simply set your script up to read the movie name from the filename?


$array = array(movie1.swf, movie2.swf); // list your ad files in here
$randfile = shuffle($array);
$file = '$randfile[1]'; // get the file from an array of your flash movies (ads)

$a = pathinfo($file);

// result:
$a['dirname'] = '/path/to'
$a['basename'] = 'youmoveiname.swf'
$a['extension'] = 'swf'
$a['filename'] = 'yourmoviename'

taken from this
http://www.codingforums.com/showthread.php?t=110411
thread

jpmad4it
03-27-2007, 06:20 PM
simply set your script up to read the movie name from the filename?


$array = array(movie1.swf, movie2.swf); // list your ad files in here
$randfile = shuffle($array);
$file = '$randfile[1]'; // get the file from an array of your flash movies (ads)

$a = pathinfo($file);

// result:
$a['dirname'] = '/path/to'
$a['basename'] = 'youmoveiname.swf'
$a['extension'] = 'swf'
$a['filename'] = 'yourmoviename'

taken from this
http://www.codingforums.com/showthread.php?t=110411
thread

Yeah great that would work!!

Ahhhhhh......the problem is that the swf files are constantly changed / added / removed so the array would have to be constantly monitored and changed. It would require a lot of maintenance.

rafiki
03-27-2007, 06:27 PM
Yeah great that would work!!

Ahhhhhh......the problem is that the swf files are constantly changed / added / removed so the array would have to be constantly monitored and changed. It would require a lot of maintenance.
not really $array = readdir(/ads/swfs/);
?
if this does work hows bout some rep :P

jpmad4it
03-27-2007, 08:41 PM
not really $array = readdir(/ads/swfs/);
?
if this does work hows bout some rep :P

Ah I see. I will try this tomorrow and i'll definately give you rep if it works!

I may need some help along the way though :o

rafiki
03-27-2007, 08:44 PM
I may need some help along the way though :o
well this is the place for it, just come along and post your problems (like before) and we'll all be glad to help
Thanks
(hope it works)

jpmad4it
03-28-2007, 10:52 AM
well this is the place for it, just come along and post your problems (like before) and we'll all be glad to help
Thanks
(hope it works)


I've just found out that the tpl file I am working with doesn't support PHP. The system I am using is Cubcart. For every tpl file there is a PHP file that sends all the variables to the relevant tpl file. So maybe I need to code the index.php file first and then send the variables to the tpl file???

Now I'm confused!!

jpmad4it
03-28-2007, 11:09 AM
I added this code to the index.php file:

include("http://www.mysite.com/banners/index.php");
$body->assign("FLASH_ROT",$box_content);

And when i view the webpage the banner rotator is there! My problem is now trying to position the flash using CSS - the problem is that the rotator just sits right at the top of the page and seems to ignore any CSS command i apply to it??

jpmad4it
03-28-2007, 11:23 AM
WHAY! I did it :D

It works!

I added this code to the index.php file:

$file = file_get_contents("http://www.mysite.com/banners");
$body->assign("FLASH_ROT", $file);

And then called it in index.tpl using {FLASH_ROT}

I'm chuffed with myself LOL



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum