Jump to content

Template file változó átadás hiba


Recommended Posts



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ó?


if (!defined('_PS_VERSION_'))

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'); 

	public function install()
	if (Shop::isFeatureActive()) {

    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');


<!-- Block mymodule -->
<div id="mymodule_block_home" class="block">
  <div class="block_content">
    <p class="mycss">Hello,
           {if isset($message) && $message}
               Nincs üzenet!
<!-- /Block mymodule -->
Edited by Kropatics (see edit history)

Share this post

Link to post
Share on other sites

Igen 1.7. PS-ről van szó, bocsánat. :)

Ugye itt


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


Share this post

Link to post
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...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More