3

prestashop 1.4 でモジュールを作成しています。blocktest

モジュール/blocktest/blocktest.php:

...

public function hookLeftColumn($params)
{
    global $smarty;
    $smarty->assign(array(
        'test' => 'test'
    ));
    return $this->display(__FILE__, 'blocktest.tpl');
}

public function hookHeader()
{
    Tools::addCSS($this->_path.'blocktest.css', 'all');
}

モジュール/blocktest/blocktest.css:

* { background-color: red; }


問題:

私のcssは含まれていません。


私が試したこと:

ではadmin > preferences > performances > smarty、キャッシュをnoに設定し、コンパイルを に強制しましたyes。ではadmin > preferences > performances > smarty、キャッシュは に設定されていnoます。

既存のモジュールは同じ css include: を使用しTools::addCSS($this->_path.'blocktest.css', 'all');ますが、css ファイルは<themeName>/css/modules/<moduleName>/<moduleName>.css. $this->_path がモジュールフォルダーを指しているため、これは奇妙です: modules/<moduleName>/.

とにかく、cssファイルをに入れようとしましたが 、うまくいき<themeName>/css/modules/blocktest/blocktest.cssません。多分私は何かが欠けている

4

3 に答える 3

5

Did you remember about registering a hook for the header during module's installation?

function install() {
    if (!parent::install())
        return false;
    if (!$this->registerHook('header'))
        return false;
    return true;
}

Without it you will have to use "transplant module" function from Admin > Modules > Positions, to do this. Always check with tools like Firebug to verify whether your files are there.

Also, I think there is something missing, can you supply us with the full code of your module? Please, provide us with a Prestashop version that you use as well.

于 2011-08-11T22:30:35.230 に答える
1

$this->_path がモジュール フォルダーを指しているため、これは奇妙です: modules//

はい、それは(奇妙な)ですが... addCSS関数では、(モジュール)テーマcssフォルダーでオーバーライドされます

public static function addCSS($css_uri, $css_media_type = 'all')
{
  global $css_files;
   ...
  $css_uri = str_replace(__PS_BASE_URI__.'modules/', __PS_BASE_URI__.'themes/'._THEME_NAME_.'/css/modules/', $css_uri, $different);
   ...
}
于 2012-02-19T11:42:03.693 に答える