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

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

Related

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

Get in tpl file name of hook/position

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

Need assistance with Prestashop label code

I want to add a Best Seller label to products in Prestashop 1.6, on both product list and product pages, the same as the labels for New Products. Can anybody point me in the right direction to accomplishing this, if it is possible, i.e will it require a controller etc.
At this stage all I have tried is simply,
{if isset($best_sellers) && $best_sellers|#count > 0}
<span class="bestseller">
<label>{l s='best seller' mod='modulename'}</label>
</span>
{/if}
This did not work. I don't need any help with the css, I can handle that. Thanks
Hello again,
Using some of the information you gave me below I have come up with the following to add a best seller label to my custom module without using an override.
Following is the function:
public function getcustomBestSellersLabel($params)
{
$id_product = (int)$params['product']['id_product'];
return Db::getInstance()->executeS('SELECT `id_product`, `sale_nbr` AS customnbr FROM '._DB_PREFIX_.'product_sale ps WHERE `id_product` = '.(int)$id_product.' ORDER BY `customnbr` DESC LIMIT 5');
}
and in my hook
public function hookdisplayCustomBestSellersTag($params)
{
$id_product = (int)Tools::getValue('id_product');
if (!$this->isCached('custombestsellertag.tpl', $this->getCacheId($id_product))) {
$custombestsellers = CustomModule::getCustomBestSellersLabel($params);
$this->context->smarty->assign(array(
'custombestsellers' => Module::getInstanceByName('CustomModule')->getCustomBestSellersLabel($params),
'id_product' => $id_product,
));
}
return $this->display(__FILE__, 'views/templates/front/custombestsellerlabel.tpl', $this->getCacheId());
}
and in my tpl
{if (isset($custombestsellers) && $custombestsellers)}
<span class="custom-best-seller-label">
<label>{l s='best seller' mod='CustomModule'}</label>
</span>
{/if}
This actually works except for one problem, the LIMIT doesn't work. I have tested it in phpMyAdmin where it does work. I have tested it with LIMIT 5 and there is no change, instead all products in the product_sale database table are showing a label.
Can you give me some advice on how to fix this problem.
Thank you.
It's much more complicated than that, to achieve that you need:
create override of Product.php method called getProductProperties
check if product is in TOP X in terms of sales in PREFIX_product_sale table
if so, mark it as a bestseller by adding a new variable (alternative is to do this directly in SQL statement)
if you'll do everything properly and new variable will be available you would have a chance to use it like this:
{if $product.is_bestseller}bestseller label{/if}

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.

How to edit the registration page in prestahsop

I want to add a field that is group access in the registration page of my Prestashop store so will any one help me out with the solution?
create all groups via the admin panel
modify authentification.tpl in your theme folder :
Add the new field :
<input type="radio" name="id_group" id="id_group1" value="1" {if isset($smarty.post.id_group) && $smarty.post.id_group == '1'}checked="checked"{/if} />
<input type="radio" name="id_group" id="id_group2" value="2" {if isset($smarty.post.id_group) && $smarty.post.id_group == '2'}checked="checked"{/if} />
Modify the controller AuthController.php (where the user is saved)
$id_group = (Tools::getIsset('id_group')) ? Tools::getValue('id_group') : 1;
On the official forum i found this : http://www.prestashop.com/forums/topic/59057-solved-change-user-group-after-registration/
I hope it can help.
Good luck