Page 1 of 3 123 LastLast
Results 1 to 10 of 25
  1. #1
    Join Date
    Jul 2007
    Location
    Jakarta
    Posts
    358
    Plugin Contributions
    0

    Default tpl_footer & tpl_header text based on language

    I want to control a small snippet of text in the my header and footer depending the language chosen.

    Can anyone give me a code snippet that I can stick into the header and footer files to check for this?

  2. #2
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: tpl_footer & tpl_header text based on language

    echo MY_TEXT
    and then define MY_TEXT in the language file for each language. E.g.
    define('MY_TEXT','Hello'); in english.php
    define('MY_TEXT','Bonjour'); in french.php
    define('MY_TEXT','Hola'); in spanish.php
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

  3. #3
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: tpl_footer & tpl_header text based on language

    Define the text as the value of a constant in a language file, and it will be swapped automatically when you switch languages.

    You should have a separate version of all language files for each language.

    ...Like Kuroi describes above...

  4. #4
    Join Date
    Jul 2007
    Location
    Jakarta
    Posts
    358
    Plugin Contributions
    0

    Default Re: tpl_footer & tpl_header text based on language

    Quote Originally Posted by kuroi View Post
    and then define MY_TEXT in the language file for each language. E.g.

    Wow! Thanks! That was easy.

  5. #5
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: tpl_footer & tpl_header text based on language

    Zen Cart Magic

    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

  6. #6
    Join Date
    Jun 2006
    Location
    My family and I live in Brighton, England
    Posts
    982
    Plugin Contributions
    0

    Default Re: tpl_footer & tpl_header text based on language

    I've been attempting to put the information in this thread to use but have run into a snag - I can't really get my head around the logic.

    I would like to have a home link in the header for each of the two site languages, each leading to their respective home locations. I've added this to tpl_header.php:
    <li><?php echo '<a href="' . zen_href_link(FILENAME_HOME_IT, '', 'SSL') . '">' . BOX_INFORMATION_HOME_IT . '</a>'; ?></li>
    and defined it in italian.php. On the Italian side it works as intended. However, on the English side, in the header bar, you see:
    BOX_INFORMATION_HOME_IT
    Since the tpl_header.php file is not located in a language file, it makes sense that it would be visible, but I can't quite immagine how to properly resolve it. Can I just add a language file within my includes/templates/my_template/? Somehow that doesn't seem quite kosher...

  7. #7
    Join Date
    Jun 2006
    Location
    My family and I live in Brighton, England
    Posts
    982
    Plugin Contributions
    0

    Default Re: tpl_footer & tpl_header text based on language

    Hmmm... OK, after re-reading what I posted it occured to me that I had not defined the English side of things. So, in english.php:
    // Italian language home link
    define('BOX_INFORMATION_HOME_IT', '');
    Leaving it blank seemed to work.

    Now, how can I properly direct this link to the Italian language home page?
    <li><?php echo '<a href="' . zen_href_link(FILENAME_HOME_IT, '', 'SSL') . '">' . BOX_INFORMATION_HOME_IT . '</a>'; ?></li>
    Usually I would do something like:
    <li class="submenu"><a href="http://www.beadedlilydesigns.com/?language=it">Home</a>
    but then the file names are not being utilized and so wouldn't be recognized by the language files, right? Ow - My head!!

  8. #8
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: tpl_footer & tpl_header text based on language

    If you are wanting to (say) go to the Italian homepage from an English page, you would also (first) want to switch the language setting. When that happens, the home page will show in Italian, and the rest of the site will display in Italian until you switch back to English.
    Or are you not wanting to switch languages in the session? That sounds tricky, forcing the page to display in a language other than the one set. You might be able to force it by adding to the url "&language=italian" in whatever form that should take... maybe?? Would that reset the session value?? Would it be read by the files using $_SESSION['language'] ?

    Yes. my head hurts too...

  9. #9
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: tpl_footer & tpl_header text based on language

    The page is not a single file, and the language files are called by the destination files, not in the url. I think you will need to make the session language switch before the homepage link happens, or maybe you can do them simultaneously. Is that something that javascript can do that PHP can't?

  10. #10
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default Re: tpl_footer & tpl_header text based on language

    If I remember correctly, zen stores the language you selects in session. So the language param appears in the url only at the first time you select the language.
    So if you visit a page for too long and the session expires, then you are switched back to the default languages.

    Most seo modules (excluding ultimate seo url, I believe) addresses this problem by always inserting the language code in the links.
    I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

 

 
Page 1 of 3 123 LastLast

Similar Threads

  1. load tpl_header based on device type
    By solo_400 in forum General Questions
    Replies: 7
    Last Post: 22 Mar 2016, 07:03 PM
  2. v139h tpl_header.php how to set different logos for each language?
    By ilmarchez in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 25 Mar 2013, 11:11 PM
  3. v139h custom tpl_header based on language
    By Ruts67 in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 18 Feb 2012, 07:18 AM
  4. now in your cart in another language (tpl_header.php)
    By cinziapdl in forum Addon Language Packs
    Replies: 12
    Last Post: 10 Feb 2012, 12:31 AM
  5. Home & Log in URL in tpl_header.php
    By miles in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 18 Oct 2006, 05:32 AM

Posting Permissions

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