Jump to content

How to access links outside hook_top


Rahul Sonar

Recommended Posts

I am very new to prestashop and was doing some design work.

I needed to access the header_links, that is permanent link block outside the hook. But I found that smarty class does not return this block alone. When u access

$smarty->_tpl_vars['HOOK_TOP'], it returns a string of all html containing other element as well. So, how can I access permanent links only ?

Link to comment
Share on other sites

I'm not sure which file you are trying to add it too, but you can try including modules/blockpermanentlinks/blockpermanentlinks.php, then use code like the following:

$blockPermanentLinks = new BlockPermanentLinks();
$blockPermanentLinksTop = $blockPermanentLinks->hookTop(NULL);

Link to comment
Share on other sites

Change header.php from:

<?php

// P3P Policies (http://www.w3.org/TR/2002/REC-P3P-20020416/#compact_policies)
header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"');

require_once(dirname(__FILE__).'/init.php');

/* CSS */
$css_files[_THEME_CSS_DIR_.'global.min.css'] = 'all';

/* Hooks are volontary out the initialize array (need those variables already assigned) */
$smarty->assign(array(
   'HOOK_HEADER' => Module::hookExec('header'),
   'HOOK_LEFT_COLUMN' => Module::hookExec('leftColumn'),
   'HOOK_TOP' => Module::hookExec('top'),
   'static_token' => Tools::getToken(false),
   'token' => Tools::getToken(),
   'priceDisplayPrecision' => _PS_PRICE_DISPLAY_PRECISION_,
   'content_only' => intval(Tools::getValue('content_only'))
));

if(isset($css_files) AND !empty($css_files)) $smarty->assign('css_files', $css_files);
if(isset($js_files) AND !empty($js_files)) $smarty->assign('js_files', $js_files);

$smarty->display(_PS_THEME_DIR_.'header.tpl');

?>



to:

<?php

// P3P Policies (http://www.w3.org/TR/2002/REC-P3P-20020416/#compact_policies)
header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"');

require_once(dirname(__FILE__).'/init.php');
include_once(_PS_MODULE_DIR_.'/blockpermanentlinks/blockpermanentlinks.php'); 

$blockPermanentLinks = new BlockPermanentLinks();

/* CSS */
$css_files[_THEME_CSS_DIR_.'global.min.css'] = 'all';

/* Hooks are volontary out the initialize array (need those variables already assigned) */
$smarty->assign(array(
   'HOOK_HEADER' => Module::hookExec('header'),
   'HOOK_LEFT_COLUMN' => Module::hookExec('leftColumn'),
   'HOOK_TOP' => Module::hookExec('top'),
   'HOOK_LINKS' => $blockPermanentLinks->hookTop(NULL),
   'static_token' => Tools::getToken(false),
   'token' => Tools::getToken(),
   'priceDisplayPrecision' => _PS_PRICE_DISPLAY_PRECISION_,
   'content_only' => intval(Tools::getValue('content_only'))
));

if(isset($css_files) AND !empty($css_files)) $smarty->assign('css_files', $css_files);
if(isset($js_files) AND !empty($js_files)) $smarty->assign('js_files', $js_files);

$smarty->display(_PS_THEME_DIR_.'header.tpl');

?>



You can then add the following wherever you want just the permanent links block to appear in header.tpl:

{$HOOK_LINKS}

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...