Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New Coder
    Join Date
    Jan 2006
    Posts
    89
    Thanks
    3
    Thanked 0 Times in 0 Posts

    PHP in the <embed> tag.....is it possible?

    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

  • #2
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    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.

    PHP Code:
    <param name="movie" value="<?php echo $movieName?>">
    This would work fine.

  • #3
    New Coder
    Join Date
    Jan 2006
    Posts
    89
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by aedrin View Post
    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.

    PHP Code:
    <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

  • #4
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    simply set your script up to read the movie name from the filename?
    PHP Code:
    $array = array(movie1.swfmovie2.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
    printing the filename with out extension
    thread

  • #5
    New Coder
    Join Date
    Jan 2006
    Posts
    89
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by rafiki View Post
    simply set your script up to read the movie name from the filename?
    PHP Code:
    $array = array(movie1.swfmovie2.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
    printing the filename with out extension
    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.

  • #6
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    Quote Originally Posted by jpmad4it View Post
    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

  • #7
    New Coder
    Join Date
    Jan 2006
    Posts
    89
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by rafiki View Post
    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

  • #8
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    Quote Originally Posted by jpmad4it View Post
    I may need some help along the way though
    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)

  • #9
    New Coder
    Join Date
    Jan 2006
    Posts
    89
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by rafiki View Post
    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!!

  • #10
    New Coder
    Join Date
    Jan 2006
    Posts
    89
    Thanks
    3
    Thanked 0 Times in 0 Posts
    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??

  • #11
    New Coder
    Join Date
    Jan 2006
    Posts
    89
    Thanks
    3
    Thanked 0 Times in 0 Posts
    WHAY! I did it

    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •