How to call PHP in a TPL file?

Discussion in 'HTML & Website Design' started by LiftBigEatBig, Nov 3, 2008.

  1. #1
    I'm running a clipshare tube site, and it uses .tpl files. I want to add some ad rotator script in php. However, it obviously won't run properly in a tpl file. Any suggestions on how to pull it off?

    The only options I can see is editting the htaccess so tpl can run php, or linking to the php file in the tpl. I'm not sure how to do either.

    Any help is greatly appreciated! Thanks.
     
    LiftBigEatBig, Nov 3, 2008 IP
  2. iwtmmo

    iwtmmo Active Member

    Messages:
    832
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    58
    #2
    I have included php in .tpl file using

    {php} your php code {php}
     
    iwtmmo, Nov 4, 2008 IP
  3. witsols

    witsols Peon

    Messages:
    102
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You can just put the iframe code into a tpl file as it is, say:

    <IFRAME SRC="http://www.dream-dating.org/index.php" WIDTH=100 HEIGHT=100>
    </IFRAME>


    Zubair.
     
    witsols, Nov 4, 2008 IP
  4. garrettheel

    garrettheel Peon

    Messages:
    341
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Well, the thing is that you're not supposed to need to use it in the tpl files. All of the logic should be done in the .php file and set as variables that you can use in the .tpl file. But if you insist on using it in the .tpl file, this can be done with {literal}<?php echo "php goes here"; ?>{/literal}

    http://www.smarty.net/manual/en/language.function.literal.php
     
    garrettheel, Nov 4, 2008 IP
  5. LiftBigEatBig

    LiftBigEatBig Well-Known Member

    Messages:
    302
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    123
    #5
    Thanks for all the great tips guys.
     
    LiftBigEatBig, Nov 4, 2008 IP