Jump to content

Creating a module


Recommended Posts

Hi, I'm very new to Prestashop and i have issues trying to create my first module.

Aim of the module :

I want to create a page in my theme which lists each link of CMS pages related to a custom CMS category

 

I created a "AKblog" module in the root's modules/ folder, created a AKblog.php file to construct my module, and used this code to register a new hook that i'll call from my .tpl files when needed : 


<?php
if (!defined('_PS_VERSION_')){exit;}
 
class AKblog extends Module{
public function __construct(){
    $this->name = 'AKblog';
    $this->tab = 'front_office_features';
    $this->version = '1.0.0';
    $this->author = 'xxx';
   $this->need_instance = 0;
    $this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_);
   $this->bootstrap = true;
 
    parent::__construct();
 
    $this->displayName = $this->l('AK - Blog');
    $this->description = $this->l('xxx');
 
    $this->confirmUninstall = $this->l('xxx');
 
    if (!Configuration::get('xxx')){$this->warning = $this->l('xxx');}
}
public function install(){
if (!parent::install())
    return false;
return true;
if (Shop::isFeatureActive())
    Shop::setContext(Shop::CONTEXT_ALL);
return parent::install() && $this->registerHook('akbloghook');
}
public function uninstall(){
 if (!parent::uninstall())
    return false;
 return true;
}
public function hookAkbloghook($params){
  return $this->display(__FILE__, 'AKblog.tpl');
}
 
}
 
?>

My AKblog.tpl is located in ./modules/AKblog/views/templates/hook/ (and also in ./modules/AKblog/views/templates/front/ to test) and contains basic html code to test the module.

I call the hook in one of my tpl file like this

{hook h='akbloghook'}

Nothing from my AKblog.tpl content is displayed...

Can someone help me understand what i'm doing wrong ? (of course i installed the module via the backoffice)

 

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