Search code examples
prestashopprestashop-1.6

Get telephone number in Prestashop 1.6


Is there a way to get a telephone number of the store in any place of template? In blockcontact.tpl we have:

{if $telnumber != ''}
        <p class="tel">
            <span class="label">{l s='Phone:' mod='blockcontact'}</span>{$telnumber|escape:'html':'UTF-8'}
        </p>
    {/if}

Can I take that $telnumber out of hooks at top of my page in header.tpl?


Solution

  • In blockcontact.tpl you have the {$telnumber} because is assigned from the controller of this template, in this case blockcontact.php file.

    Line +-185:

    $smarty->assign(array(
    
                'telnumber' => Configuration::get('BLOCKCONTACT_TELNUMBER'),
                ...
    

    Here you can see the way that is assigned the $telnumber variable.


    Then, if you want to use this in any place, or any template, first you need to go to the Controller of the template that you need and, in the correct function use the second way that answered @sarcom:

    if it's a module probably in the function of the hook that's the template hooked, and if it's a core controller in the initContent() function.

    And then you can use the {$telnumber} in the template.

    If you need to edit a core controller, the best way is to use the override feature.