Kropatics Posted April 6, 2019 Share Posted April 6, 2019 (edited) 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 --> Edited April 9, 2019 by Kropatics (see edit history) Link to comment Share on other sites More sharing options...
pattila01 Posted April 7, 2019 Share Posted April 7, 2019 Feltételezem egyhetes ps-ről van szó ahogyan látom. Ezt mindig írd bele a kérdésedbe mert nyilván fontos, hogy milyen verziószámmal dolgozol. Mi a baj a css-el? Nem tölt be? Mi a hiba? Link to comment Share on other sites More sharing options...
Kropatics Posted April 9, 2019 Author Share Posted April 9, 2019 Igen 1.7. PS-ről van szó, bocsánat. Ugye itt assets/css/mymodule.css elhelyeztem a css-t: p.mycss {font-size:22px;} de a template-ben nem változik semmi. MIért? A template fileban külön be kell még húzni a css-t is? <link rel="stylesheet" type="text/css" href="mymodule.css"> Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now