Looking for a smarty to help with a smarty issue! (Should be simple)

Discussion in 'Programming' started by JWRmedia, Nov 4, 2008.

  1. #1
    I can't find the right syntax for this.

    In all of my site's PHP pages, I have the following:

    1 file named: servername.php

    Inside that file I have:

    <?php
    //Server 1
    $servername = "Server Alpha";
    
    //Server 2
    //$servername = "Server Bravo";
    ?>
    Code (markup):
    When I want to implement it on a regular php page of my site, I just use

    include("servername.php");
    Code (markup):
    In the <head> and this:

    <?php echo $servername; ?>
    Code (markup):
    In the body.

    This works fine. The reason Im doing this is because if one server goes down, I can simply update the domain's nameservers and change the variable in servername.php to update all the pages within the site and remind me which server the domain is pointing to.

    The problem I'm running in to is that I have one file, header.tpl which I need to insert this in to and I am not too good with smarty template files.

    Does anyone have any suggestions as to how I can implement this feature inside a .tpl file?

    Any help is appreciated. Thanks.
     
    JWRmedia, Nov 4, 2008 IP
  2. shineDarkly

    shineDarkly Banned

    Messages:
    241
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    enclose it inside {PHP}{/PHP} tags and it will run like a regular php code
     
    shineDarkly, Nov 4, 2008 IP
  3. JWRmedia

    JWRmedia Banned

    Messages:
    499
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the tip, unfortunately it didnt work.

    Here's my site layout:

    public_html/servername.php

    Contents:

    <?php
    //Logicweb
    $servername = "Server Alpha";
    
    //HostGator
    //$servername = "Server Bravo";
    ?>
    
    Code (markup):
    Since I have cloned the sites to two different servers, I want to be able to tell which server the site is displaying from. If one server goes down, I simply update the nameservers and it points to the secondary domain.

    Instead of updating every single file, I figured I could update one file (servername.php) and it will update all the pages on my site.

    It works perfectly except for two .tpl files that I have, which will not work.

    *****
    Site note: It would be even better if I could display the server IP instead of "Alpha" or "Bravo".

    Im still toying with it but still looking for some assistance. Thank you!!!
     
    JWRmedia, Nov 4, 2008 IP