How can I do this? Please help!

Discussion in 'PHP' started by indyonline, Oct 31, 2008.

  1. #1
    Hello everyone. I have a game site that is built in PHP using smarty. I'm new to PHP and having problems editing it. I have some advertising I want to add but I want to only add it to a specific page. I can get it to go on the site but it adds it to every page.What do I need to add to the code to just get it to show on a particular page. Here is the line I added:

    <div>{include file="test.tpl"}</div>
    Code (markup):
    Somebody had mentioned to me that I need to add an "if" and the page url to the code so it would only add it if it was the page I wanted it on.

    Any help would be appreciated. thanks.
     
    indyonline, Oct 31, 2008 IP
  2. Christian Little

    Christian Little Peon

    Messages:
    1,753
    Likes Received:
    80
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Christian Little, Oct 31, 2008 IP
  3. indyonline

    indyonline Prominent Member

    Messages:
    4,626
    Likes Received:
    248
    Best Answers:
    2
    Trophy Points:
    335
    #3
    thanks for your help. That didnt work for me either. I changed /filename.php to index.html which is the page I want it on and it didnt work.
     
    indyonline, Nov 1, 2008 IP
  4. Christian Little

    Christian Little Peon

    Messages:
    1,753
    Likes Received:
    80
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Put this code in the spot you want it, then load the page. View Source it and copy everything you see here. Even if it's not the index page, you should see:

    <!-- BEGIN TEST: something.html -->
    <!-- END OF TEST -->

    
    <!-- BEGIN TEST: <?php echo $_SERVER['SCRIPT_NAME']; ?> -->
    <?php if($_SERVER['SCRIPT_NAME'] == "/filename.php") { ?>
      <div>{include file="test.tpl"}</div>
    <?php } ?>
    <!-- END OF TEST -->
    
    PHP:
     
    Christian Little, Nov 2, 2008 IP
  5. indyonline

    indyonline Prominent Member

    Messages:
    4,626
    Likes Received:
    248
    Best Answers:
    2
    Trophy Points:
    335
    #5
    Here is the code for the whole file. its trhe layout.tpl file

    I replaced the code and changed filename.php to /index.html and I get an error and the whole site quits working. The line of code is at the very bottom.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>{$Site_Title}</title>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <meta name="keywords" content="{$Site_Keywords}">
    <meta name="description" content="{$Site_Desc}">
    <link rel="stylesheet" type="text/css" media="screen" href="{$T_CSS_Tpl}default.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="{$T_CSS_Tpl}arcade.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="{$T_CSS_Tpl}global.css" />
    <script type="text/javascript" src="{$T_JS}jquery/jquery.js"></script>
    <script type="text/javascript" src="{$T_JS}jquery/jtip2.js"></script>
    <script type="text/javascript" src="{$T_JS}functions.js"></script>
    {section name=FileName loop=$JavaScript}
    <script type="text/javascript" src="{$T_JS_Tpl}{$JavaScript[FileName]}"></script>
    {/section}
    </head>
    <body style="body">
    <div style="margin: 0 auto;width:990px;padding:0;" class="box1">
      <div>{include file="header.tpl"} </div>
      <div>{include file="top_menu.tpl"}</div>
      <div><script type="text/javascript"><!--
    google_ad_client = "pub-----------";
    /* 728x15, created 6/14/08 */
    google_ad_slot = "---------";
    google_ad_width = 728;
    google_ad_height = 15;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script></div>
      <div>{include file="last_played_games.tpl"}</div>
      <div style="float:left;width:170px;padding:5px 0px 5px 5px;">{include file="left_v_menu.tpl"}</div>
      <div style="float:left;width:630px;padding:5px 0px 5px 5px;">{include file="$T_Body"}</div>
      <div style="float:right;width:170px;padding:5px 0px 5px 5px;">{include file="right_v_menu.tpl"}</div>
      <div style="float:none;clear:both;"></div>
      <div>{include file="test.tpl"}</div
      <div>{include file="footer.tpl"}</div>
    </div>
    </body>
    </html>
    Code (markup):
     
    indyonline, Nov 2, 2008 IP
  6. indyonline

    indyonline Prominent Member

    Messages:
    4,626
    Likes Received:
    248
    Best Answers:
    2
    Trophy Points:
    335
    #6
    I get an error in line 41
     
    indyonline, Nov 3, 2008 IP
  7. Christian Little

    Christian Little Peon

    Messages:
    1,753
    Likes Received:
    80
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I can't figure out why the code I sent you doesn't work. I suspect it's because you are using PearPHP instead of just standard PHP. So here's an alternative suggestion - get Open Ads. It's an open source ad program that will manage this crap for you (http://www.openads.org) or use Google Ad Manager, which is now available to anybody.

    That'll save you trying to fiddle with the code.
     
    Christian Little, Nov 4, 2008 IP