Get in tpl file name of hook/position - module

i use one module in footer and in specific page.
In footer this module have a layout, but in specific page i want another layout. In file tpl i can change layout by if/else?
I think:
{if position == 'footer'}
codecodecode
{else}
code
{/if}
possible?

Try
{if $page.page_name == 'pagename'}
codecodecode
{else}
code
{/if}
Regards

Related

How ps_linklist render footer link block?

I am having difficulty understanding how the module that deals with generating links in the prestashop footer was written. The module is the ps_linklist and inside it contains a view / template / hook / linkblock.tpl which should contain the code needed to generate the links. The problem is that the code is as follows:
{foreach $linkBlocks as $linkBlock}
<h3>{$linkBlock.title|escape:'html':'UTF-8'}</h3>
<ul>
{foreach $linkBlock.links as $link}
<li>
<a
id="{$link.id}-{$linkBlock.id}"
class="{$link.class}"
href="{$link.url|escape:'html':'UTF-8'}"
title="{$link.description|escape:'html':'UTF-8'}"
{if !empty($link.target)} target="{$link.target|escape:'html':'UTF-8'}" {/if}
>
{$link.title|escape:'html':'UTF-8'}
</a>
</li>
{/foreach}
</ul>
{/foreach}
But the generated html is different, it includes a lot of information that cannot be generated by this code, so it is impossible for me to understand how to change the column layout of this section ... how to make things easy complex ...
enter image description here

If language x then:xyz, if else then:abc

I'm trying to do function in prestashop that will show one string if it's english and another string if it's other language.
I've tried something like that but it didn't work.
{if $lang_iso == en }
english text
{else}
Other language
{/if}
That's where I want to put my code. I wanted to code be in 'Proceed to checkout' place
{l s='Proceed to checkout' d='Shop.Theme.Actions'}
Obviously there is no option to translate it in prestashop backoffice.
Use {if $lang_iso == 'en' }
en is a string.
Secondly, there is an option in back office.
Login to admin -> International->Translation.
try with :
{$this->context->language->id}
Regards

How to make different tpl depending on the name of the hook for module?

In some modules I want to make a different output of information depending on the name of the hook. How to write a working condition in the module tpl?
You can add a smarty variable with that information, eg. in the hook where you will render a tpl you could do this:
$this->context->smarty->assign('hook_origin', 'your-hook-name');
return $this->display(__FILE__, 'views/templates/hook/myTemplate.tpl');
Now in your tpl myTemplate.tpl you can evaluate the source hook:
{if $hook_origin == 'your-hook-name'}
{* Your code for this hook here *}
{elseif $hook_origin == 'your-other-hook-name'}
{* Your code for this hook here *}
{else}
{* Your code for others *}
{/if}
If you want to change the PHP file of a module then you need to override that module in your theme. And deactivate the default module of a Prestashop.
By overriding the module according to your theme, you are having full control over the PHP and template file.

change the <header> </ header> tag in a specific prestashop

Please, how can I change the tag of a specific page in prestashop (not in the whole site : not in header.tpl)?
I am on PS 1.6
thank you in advance.
What you could do is use something like in the header.tpl:
{if $page_name == 'my-account'}<meta name="WHATEVER" content="WHATEVER" />{/if}.
You can find the $page_name by looking at the <id> tag on the <body> of that specific page. Be careful though some of the $page_name are not unique, for products for example it will always be product, no matter what the specific product is.
Try with :
{if isset($page_name) && $page_name == 'YOUR PAGE'} NEW CODE {/if}
Regards

prestashop choose language in header of BO

I would like to make a header section for a fast language change. Currently I have to go to my profile to change the language.
<div id="header_changeLang" style="">
<a class="change_lang" {if $lang_iso=="lt"}style="text-decoration:underline;"{/if} href="{$thisIndex}&change_lang=4">LT</a>
<a class="change_lang" {if $lang_iso=="lv"}style="text-decoration:underline;"{/if} href="{$thisIndex}&change_lang=5">LV</a>
<a class="change_lang" {if $lang_iso=="en"}style="text-decoration:underline;"{/if} href="{$thisIndex}&change_lang=1">EN</a>
<a class="change_lang" {if $lang_iso=="ru"}style="text-decoration:underline;"{/if} href="{$thisIndex}&change_lang=6">RU</a>
</div>
{literal}
<script>
$(document).ready(function() {
$(".change_lang").each(function() {
link = $(this);
langName = link.html();
langId = link.attr("href")[link.attr("href").length-1];
link.attr("href", "index.php{/literal}{foreach $smarty.get as $param=>$val}{if $param == "controller"}?{else}&{/if}{$param}={$val}{/foreach}{literal}&change_lang="+langId);
//console.log(langName +" - "+ link.attr("href"));
});
});
</script>
{/literal}
I tried this, but I got a wrong URL. I tried to transplant the language block into DashboardzoneTwo, but something seems to be wrong. I cannot see anything.
Any way to correct the change lang block?
Try $currentIndex instead of $thisIndex
As for &change_lang=4, are you implementing some code that would handle that parameter?
For more information, open the file [ADMIN DIR]/themes/default/template/header.tpl and add {debug} somewhere, this will open a popup with all smarty variables.