I am trying to create a module to display sub categories on homepage. how do i do it?
I am trying to create a module to display sub categories on homepage. how do i do it?
I am trying to create a module to display sub categories on homepage. I have tried to use this code:
$sqlGroupsWhere = '';
$sqlGroupsJoin = '';
if (Group::isFeatureActive()) {
$sqlGroupsJoin = 'LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = c.`id_category`)';
$groups = FrontController::getCurrentCustomerGroups();
$sqlGroupsWhere = 'AND cg.`id_group` '.(count($groups) ? 'IN ('.implode(',', $groups).')' : '='.(int) Group::getCurrent()->id);
}
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT c.*, cl.`id_lang`, cl.`name`, cl.`description`, cl.`link_rewrite`, cl.`meta_title`, cl.`meta_keywords`, cl.`meta_description`
FROM `'._DB_PREFIX_.'category` c
'.Shop::addSqlAssociation('category', 'c').'
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND `id_lang` = '.(int) $idLang.' '.Shop::addSqlRestrictionOnLang('cl').')
'.$sqlGroupsJoin.'
WHERE `id_parent` = '.(int) $this->id.'
'.($active ? 'AND `active` = 1' : '').'
'.$sqlGroupsWhere.'
GROUP BY c.`id_category`
ORDER BY `level_depth` ASC, category_shop.`position` ASC');
foreach ($result as &$row) {
$row['id_image'] = Tools::file_exists_cache($this->image_dir.$row['id_category'].'.jpg') ? (int) $row['id_category'] : Language::getIsoById($idLang).'-default';
$row['legend'] = 'no picture';
but doesnot know what to put in tpl