Sziasztok!
Netes útmutató alapján írtam egy modult, de a return $this->display(__FILE__, 'mymodule.tpl'); hibaüzenet dob.
HA így próbálom, akkor jó:
global $smarty;
$smarty->assign('message', 'hello');
return $smarty->display(dirname(__FILE__).'/views/mymodule.tpl');
De ez a legjobb módja annak, hogy változókat adjunk át a template fileoknak?
És a CSS file miért nem jó?
Köszönettel:
<?php if (!defined('_PS_VERSION_')) exit; class MyModule extends Module { public function __construct() { $this->name = 'mymodule'; /* This is the 'technic' name, this should equal to filename (mycustommodule.php) and the folder name */ $this->tab = 'front_office_features'; /* administration, front_office_features, etc */ $this->version = '1.0.0'; /* Your module version */ $this->author = 'Kropatics'; /* I guess it was clear */ $this->need_instance = 0; /* If your module need an instance without installation */ $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); /* Your compatibility with prestashop(s) version */ $this->bootstrap = true; /* Since 1.6 the backoffice implements the twitter bootstrap */ $this->displayName = $this->l('My module'); /* This is the name that merchant see */ $this->description = $this->l('This is my first module.'); /* A short description of functionality of this module */ } public function initContent() { $this->context->smarty->assign('message', 'hello'); $this->context->controller->addCSS($this->_path.'assets/css/mymodule.css', 'all'); parent::initContent(); } public function install() { if (Shop::isFeatureActive()) { Shop::setContext(Shop::CONTEXT_ALL); } return parent::install() && $this->registerHook('leftColumn') && Configuration::updateValue('MYMODULE_NAME', 'mymodule'); } public function uninstall() { return parent::uninstall(); } public function hookDisplayLeftColumn($params) { //return 'Hello World'; return $this->display(__FILE__, 'mymodule.tpl'); } } ?> mymodule.tpl <!-- Block mymodule --> <div id="mymodule_block_home" class="block"> <h4>Welcome!</h4> <div class="block_content"> <p class="mycss">Hello, {if isset($message) && $message} {$message} {else} Nincs üzenet! {/if} ! </p> </div> </div> <!-- /Block mymodule -->