Last active
October 21, 2016 05:20
-
-
Save PrestaEdit/4ea5fbd7a9fe0ae69909b984f11eda3a to your computer and use it in GitHub Desktop.
renderWidget / Use hookName as template source
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* [...] | |
*/ | |
use PrestaShop\PrestaShop\Adapter\Cart\CartPresenter; | |
if (!defined('_PS_VERSION_')) | |
exit; | |
use PrestaShop\PrestaShop\Core\Module\WidgetInterface; | |
class Ps_Shoppingcart extends Module implements WidgetInterface | |
{ | |
[...] | |
public function getWidgetVariables($hookName, array $params) | |
{ | |
[...] | |
} | |
public function renderWidget($hookName, array $params) | |
{ | |
if (Configuration::isCatalogMode()) { | |
return; | |
} | |
$this->smarty->assign($this->getWidgetVariables($hookName, $params)); | |
$tplName = $hookName.'.tpl'; | |
$template_path = $this->getTemplatePath($tplName); | |
if ($template_path !== null) { | |
return $this->fetch('module:ps_shoppingcart/'.$tplName); | |
} | |
return $this->fetch('module:ps_shoppingcart/ps_shoppingcart.tpl'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$this->getTemplatePath($tplName);
was kept for backward compatibility. It's shouldn't be used with Smarty module resources ($this->fetch('module:ps_shoppingcart/xxx)
) beacuse it will give you a full path.You should implement your own method
getModuleTemplatePath
which check theme override, parent theme override and then module template :(See https://github.com/PrestaShop/PrestaShop/blob/develop/classes/module/Module.php#L2306