Aegidius Posted March 8, 2013 Share Posted March 8, 2013 (edited) Ciao a tutti Ho realizzato un modulo e l'ho installato correttamente. Nella pagina della live edit delle posizioni dei moduli lo vedo perfettamente, però senza contenuto. Questo è la classe del mio modulo. <?php if (!defined('_PS_VERSION_')) { exit(); } require __DIR__ . '/DbManager.class.php'; class AdvancedSearchModule extends Module { public function __construct() { $this->name = 'advancedsearchmodule'; $this->tab = 'Search'; $this->version = 1.0; $this->author = 'Egidio Caprino'; $this->need_instance = 0; parent::__construct(); $this->displayName = $this->l('Advanced Search'); $this->description = $this->l('Allow user to search for attributes.'); } public function install() { if (!parent::install() || !$this->registerHook('top') || !$this->registerHook('displayHome')) { return false; } return true; } public function hookTop($params) { global $smarty; $smarty->assign('features', $this->getFeatures()); return $this->display(__FILE__, 'top.tpl'); } public function hookDisplayHome($params) { global $smarty; $features = $this->getFeatures(); $smarty->assign('features', $features); $this->display(__FILE__, 'home.tpl'); } public function uninstall() { if (!parent::uninstall()) { Db::getInstance()->Execute('DELETE FROM ' . _DB_PREFIX_ . 'advancedsearchmodule'); } parent::uninstall(); } private function getFeatures() { $lang = (int) $this->context->language->id; $db = DbManager::getInstance(); $query = 'SELECT id_feature, name FROM ' . _DB_PREFIX_ . 'feature_lang WHERE id_lang = ' . $lang . ' ORDER BY name ASC'; $result = $db->query($query); $features = array(); while ($row = mysql_fetch_array($result, MYSQL_NUM)) { $features[$row[0]] = array( 'name' => $row[1], 'values' => array() ); } $query = 'SELECT ' . _DB_PREFIX_ . 'feature_value.id_feature_value, ' . _DB_PREFIX_ . 'feature_value_lang.value FROM ' . _DB_PREFIX_ . 'feature_value INNER JOIN ' . _DB_PREFIX_ . 'feature_value_lang ON ' . _DB_PREFIX_ . 'feature_value.id_feature_value = ' . _DB_PREFIX_ . 'feature_value_lang.id_feature_value WHERE id_lang = ' . $lang . ' AND ' . _DB_PREFIX_ . 'feature_value.id_feature = %s ORDER BY ' . _DB_PREFIX_ . 'feature_value_lang.value ASC'; foreach ($features as $id_feature => $name) { $result = $db->query(sprintf($query, $id_feature)); while ($row = mysql_fetch_array($result, MYSQL_NUM)) { $features[$id_feature]['values'][$row[0]] = $row[1]; } } return $features; } } Questo è il file home.tpl nella stessa cartella del file sopra. <h1> HOOK HOME </h1> Qual'è il problema? Edited March 8, 2013 by Aegidius (see edit history) Link to comment Share on other sites More sharing options...
Aegidius Posted March 8, 2013 Author Share Posted March 8, 2013 Mancava il return. 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