OK to Change Smarty Variables in Layout.tpl?

Discussion in 'TemplateCodes' started by Bronxgodzilla, May 13, 2010.

Thread Status:
Not open for further replies.
  1. Bronxgodzilla Ageless Member

    Hi

    I cannot figure how to pass a variable to LANG_TPL_BROWSE in Layout.tpl -- so here is what I did. Please tell me if I am creating a problem elsewhere I am not aware of:

    On my home page I added "Browse Categories" (code taken from the accordian file) to my main top horizontal menu. I like how the general Browse function operates. I changed my accordion file's (Left Nav) Main Categories to "List Main Categories.

    Since the Left Nav accordian.tpl uses
    Code:
    <a href="{$smarty.const.URLS}/category.php">{$smarty.const.MOD_LANG_TEMPLATECODES_TEMPLATE_CATEGORIES}
    which defaulted to "Main Categories" I created in english.php the statement,
    Code:
    MOD_LANG_TEMPLATECODES_TEMPLATE_CATEGORIES_LIST
    , giving it the variable, "List Main Categories" and added it to accordion.tpl accordingly.

    I took from accordion.tpl
    Code:
     a class="browse" href="{$smarty.const.URL}/category.php">{$smarty.const.LANG_TPL_BROWSE}</a> 
    and added it to layout.tpl so it beautifully operates from my top horizontal menu.

    So here is the problem -- I wanted to pass the string, "Browse all Categories" to LANG_TPL_BROWSE but I am sure that is a form of concatenation. So I ended up just replacing it (in layout.tpl) with
    Code:
    MOD_LANG_TEMPLATECODES_TEMPLATE_CATEGORIES
    and adding the proper string into english.php

    It works! But am I creating a problem I am not aware of? Iis LANG_TPL_BROWSE created just as a kind of shorthand?

    Thanks much much for your help in my further understanding of the code.

    BarryG
  2. seymourjames All Hands On Deck

    I am lost on this. What do you actually want to achieve?

    1. Do you want a browse tab in your top menu? If so just add this into the menu defined in layout.tpl

    <li><a href="{$smarty.const.URL}/category.php">{$smarty.const.LANG_TPL_BROWSE}</a></li>


    Now whatever you define LANG_TPL_BROWSE as (which is in langages/english.php) it will appear marked as that in the top menu and incidentally in the accordion. If you want something different in the accordion then you can change the same line in the accordion.tpl file (line 28)

    <li><a href="{$smarty.const.URL}/category.php">MY NEW TEXT</a></li>

    or visa versa. You can keep it for the accordion and just insert text into the menu item.

    2.

    Do you want to change the normal title Main Categories in the accordion to List Main Categories

    If so you change the string in modules/templatecodes/language/english.php

    Here at line 30

    define('MOD_LANG_TEMPLATECODES_TEMPLATE_CATEGORIES', 'Main Categories');
  3. Bronxgodzilla Ageless Member

    Thank you for answering David. Sorry to be sounding confusing. I'd already accomplished everything you point out, and everything is working perfectly - I have different titles for different Browse actions.

    My question was I didn't know how or where from the variable "LANG_TPL_BROWSE" came from and didn't want to break anything by my removing it. That you now say that passing any text into <a href="{$smarty.const.URL}/category.php"> answers my question totally, and gives me a whole new sense of freedom & awareness regarding smarty.

    Thanks David.


  4. seymourjames All Hands On Deck

    LANG_TPL_BROWSE is defined in root directory /languages/english.php . You can rename it to anything you like. It will not break anything.
  5. Bronxgodzilla Ageless Member

    Thanks David and Mike
    I have a far greater hands on perception on creating / passing variables and making the templates do what I want. Sigma is the greatest yet. Thanks again for all your help. Can't wait to work on the External Listings and External Search Results modules, not to mention the far far greater possibilities for my new client with the Custom Plugins Modules. Seems Imagination is the limit.

    BarryG
Thread Status:
Not open for further replies.

Share This Page