question about smarty

Discussion in 'PHP' started by sudhakararaog, Nov 5, 2009.

  1. #1
    i am using smarty template engine at work place, following is the situation

    i already have 1 template that has already been created example = http://localhost/sites/template1.com this works fine

    following is the folder structure i have for smarty on xampp

    1. C:\xampp\htdocs\sites\template1.com where i have .htaccess index.php and siteconf.php

    2. C:\xampp\htdocs\sites\_templates\templates\template1


    in the siteconf.php file there are all the major variables defined which are accessed in other tpl file of the templates example in aboutus page, contactus page etc of this template1

    now i have created another template called template2 and this also has the same structure

    1. C:\xampp\htdocs\sites\template2.com where i have .htaccess index.php and siteconf.php

    2. C:\xampp\htdocs\sites\_templates\templates\template2


    my question is the look and feel when i access
    http://localhost/sites/template1.com and
    http://localhost/sites/template2.com

    is the same the only thing that needs to be done is for template2 when i access http://localhost/sites/template2.com ONLY the header image should be different compared to the header i have for http://localhost/sites/template1.com this is the only change i need

    i am not aware as to the php code i need to write so that when i access http://localhost/sites/template2.com the header image changes and this new header image remains for the entire pages of http://localhost/sites/template2.com

    presently in header.tpl of template1 is written as follows

    {if strpos($Data.KEYWORD,"rv rental") === false}
    <div class="header" style="background:url(images/header_{$siteData.COUNTRY3}.gif) no-repeat top left;">
    {else}
    <div class="header" style="background:url(images/header_{$siteData.COUNTRY3}_rv.gif) no-repeat top left;">
    {/if}
    </div>

    so i need to change the {if} {else} where i need to mention that if i am accessing http://localhost/sites/template2.com then the header image should be different.

    any help will be greatly appreciated.

    please advice.

    thanks.
     
    sudhakararaog, Nov 5, 2009 IP
  2. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #2
    JAY6390, Nov 5, 2009 IP
  3. sudhakararaog

    sudhakararaog Member

    Messages:
    73
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    thanks for replying

    i have used {$smarty.server.SCRIPT_NAME} and this is displaying the path of which is quite good now using the existing code

    out put = sites/website1.com

    {if strpos($siteData.KEYWORD,"rv rental") === false}
    <div class="header" style="background:url(images/header_{$siteData.COUNTRY3}.gif) no-repeat top left;">
    {else}
    <div class="header" style="background:url(images/header_{$siteData.COUNTRY3}_rv.gif) no-repeat top left;">
    {/if}


    which was done already by other developers and i have to follow the same logic, how can i check

    if the output sites/website1.com or sites/website2.com contains the word
    website1 or website2 using the above logic so that i can display the relavant header image

    there needs to be 3 conditions to be checked so i guess an else if is needed.

    condition1 = display images/header_{$siteData.COUNTRY3}.gif
    condition2 = display images/header_{$siteData.COUNTRY3}.jpg
    else condition3 = display images/header_{$siteData.COUNTRY3}.png


    please advice.
     
    sudhakararaog, Nov 5, 2009 IP
  4. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #4
    {if $smarty.server.SCRIPT_NAME == 'script_name_here'}

    something like that should be fine
     
    JAY6390, Nov 5, 2009 IP
  5. sudhakararaog

    sudhakararaog Member

    Messages:
    73
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #5
    thanks a lot that worked.
     
    sudhakararaog, Nov 5, 2009 IP
  6. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #6
    No problem :)
     
    JAY6390, Nov 5, 2009 IP