Jump to content

Modulo solo me permite engancharlo en el hook displayHome y en displayHeader


Recommended Posts

Buenas comunidad estoy intentando crear un modulo, el instala bien pero solo me permite enganchar a dos hooks no esta habilitado para otros hooks como podria solucinar eso?. Necesito ayuda.
Ese es el codigo que del php ya los demas archivos son tpl, css y js

Quote

 

<?php
if(!defined('_PS_VERSION_'))
exit;
class mi_primer_module extends Module{
    public function __construct()
    {
    $this->name = 'mi_primer_module'; //nombre del módulo el mismo que la carpeta y la clase.
    $this->tab = 'front_office_features'; // pestaña en la que se encuentra en el backoffice.
    $this->version = '1.0.0'; //versión del módulo
    $this->author ='Luis Jordán: https://luisjordan.net'; // autor del módulo
    $this->need_instance = 0; //si no necesita cargar la clase en la página módulos,1 si fuese necesario.
    $this->ps_versions_compliancy = array('min' => '1.7.x.x', 'max' => _PS_VERSION_); //las versiones con las que el módulo es compatible.
    $this->bootstrap = true; //si usa bootstrap plantilla responsive.

    parent::__construct(); //llamada al constructor padre.

    $this->displayName = $this->l('Mi primer módulo'); // Nombre del módulo
    $this->description = $this->l('Módulo de prueba.'); //Descripción del módulo
    $this->confirmUninstall = $this->l('¿Estás seguro de que quieres desinstalar el módulo?'); //mensaje de alerta al desinstalar el módulo.

    $this->templateFile = 'module:mi_primer_module/views/templates/hook/mi_primer_modulo.tpl';
    }
    public function install()
    {
        return (parent::install()
        && $this->registerHook('displayHeader') // Registramos el hook dentro de las cabeceras.
        && $this->registerHook('displayCarrierExtraContent')
        );

        $this->emptyTemplatesCache();

        return (bool) $return;
    }
    public function hookDisplayHeader()
    {
        $this->context->controller->addJS($this->_path . 'views/js/miPrimerModulo.js');
        $this->context->controller->addCSS($this->_path . 'views/css/miPrimerModulo.css');
    }

    public function hookDisplayHome(){
        return $this->display(__FILE__, 'views/templates/hook/mi_primer_modulo.tpl');
    }
    public function renderWidget($hookName = null, array $configuration = [])
    {
        if ($hookName == null && isset($configuration['hook'])) {
            $hookName = $configuration['hook'];
        }

        $this->smarty->assign($this->getWidgetVariables($hookName, $configuration));
        $this->context->smarty->assign(array(
            'id_module' => $this->id,
            'hookName' => $hookName,
        ));

        return $this->fetch('module:ps_mi_primer_module/views/templates//mi_primer_modulo.tpl');
    }
    public function uninstall()
    {
      $this->_clearCache('*');

      if(!parent::uninstall() || !$this->unregisterHook('displayHome'))
         return false;

      return true;
    }

   
}

?>

 

 

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