Jump to content

[SOLVED] Checking language variables value inside tpl file


skech

Recommended Posts

Hello to all,

 

It's been  only a few months since I started dealing with Prestashop and I am very pleased with the Project in general !

a few thing about me to let you help me more efficiently. I m using 1.6 version at this moment.I have a little experience with Object Oriented php and MVC way of building applications, as I used to code without objects (procedural). My HTML and CSS level I think can be discribed as "beginer to intermediate"..Very liitle experience with Smarty.Anyway, to the point :

 

While customising the default-bootstrap theme for my project I decided to use the search box provided by the "Top Horizontal menu" module instead of the Quick Search module. Since this search box does not have a placeholder to add the Word search inside I decided to add one by editing my themes'  blocktopmenu.tpl file. I also thought that it would be a good idea to have the word "Search" translated depending on the choosen language. So here is my fast "solution" :

 

1.Editing  file  (installation folder)/themes/default-bootstrap/modules/blocktopmenu/blocktopmenu.tpl

 

 I changed the code, adding the code between {if $MENU_SEARCH}... {/if} as follows :

{if $MENU_SEARCH}
                <li class="sf-search noBack" style="float:right">
                    <form id="searchbox" action="{$link->getPageLink('search')|escape:'html':'UTF-8'}" method="get">
                        <p>
                            <input type="hidden" name="controller" value="search" />
                            <input type="hidden" value="position" name="orderby"/>
                            <input type="hidden" value="desc" name="orderway"/>
                            {if $lang_iso=='el'}
                            <input type="text" name="search_query" placeholder="Αναζήτηση..." value="{if isset($smarty.get.search_query)}{$smarty.get.search_query|escape:'html':'UTF-8'}{/if}" />
                            {elseif $lang_iso=='en'}
                            <input type="text" name="search_query" placeholder="Search..." value="{if isset($smarty.get.search_query)}{$smarty.get.search_query|escape:'html':'UTF-8'}{/if}" />
                            {else}
                            <input type="text" name="search_query" placeholder="Suchen..." value="{if isset($smarty.get.search_query)}{$smarty.get.search_query|escape:'html':'UTF-8'}{/if}" />
                            {/if}
                        </p>
                    </form>
                </li>
            {/if}
        </ul>
    </div>
    <!--/ Menu -->
{/if}

It works. But I would like to know if it is ok to use it this way or should I use another, more sophisticated way of doing the same thing.

 

I attached the whole blocktopmenu.tpl file to check

 

Thanks in advance!

blocktopmenu.txt

Edited by skech (see edit history)
Link to comment
Share on other sites

Hello to all,

 

It's been  only a few months since I started dealing with Prestashop and I am very pleased with the Project in general !

a few thing about me to let you help me more efficiently. I m using 1.6 version at this moment.I have a little experience with Object Oriented php and MVC way of building applications, as I used to code without objects (procedural). My HTML and CSS level I think can be discribed as "beginer to intermediate"..Very liitle experience with Smarty.Anyway, to the point :

 

While customising the default-bootstrap theme for my project I decided to use the search box provided by the "Top Horizontal menu" module instead of the Quick Search module. Since this search box does not have a placeholder to add the Word search inside I decided to add one by editing my themes'  blocktopmenu.tpl file. I also thought that it would be a good idea to have the word "Search" translated depending on the choosen language. So here is my fast "solution" :

 

1.Editing  file  (installation folder)/themes/default-bootstrap/modules/blocktopmenu/blocktopmenu.tpl

 

 I changed the code, adding the code between {if $MENU_SEARCH}... {/if} as follows :

{if $MENU_SEARCH}
                <li class="sf-search noBack" style="float:right">
                    <form id="searchbox" action="{$link->getPageLink('search')|escape:'html':'UTF-8'}" method="get">
                        <p>
                            <input type="hidden" name="controller" value="search" />
                            <input type="hidden" value="position" name="orderby"/>
                            <input type="hidden" value="desc" name="orderway"/>
                            {if $lang_iso=='el'}
                            <input type="text" name="search_query" placeholder="Αναζήτηση..." value="{if isset($smarty.get.search_query)}{$smarty.get.search_query|escape:'html':'UTF-8'}{/if}" />
                            {elseif $lang_iso=='en'}
                            <input type="text" name="search_query" placeholder="Search..." value="{if isset($smarty.get.search_query)}{$smarty.get.search_query|escape:'html':'UTF-8'}{/if}" />
                            {else}
                            <input type="text" name="search_query" placeholder="Suchen..." value="{if isset($smarty.get.search_query)}{$smarty.get.search_query|escape:'html':'UTF-8'}{/if}" />
                            {/if}
                        </p>
                    </form>
                </li>
            {/if}
        </ul>
    </div>
    <!--/ Menu -->
{/if}

It works. But I would like to know if it is ok to use it this way or should I use another, more sophisticated way of doing the same thing.

 

I attached the whole blocktopmenu.tpl file to check

 

Thanks in advance!

As long as no one has another way to provide or tell me if I am wrong somewhere and it works for me I mark it as Solved.

Thanks a lot..

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...