Jump to content

Insertar c贸digo PHP en head.tpl


Boira

Recommended Posts

Buenas tardes a todos,

estoy tratando de integrar GetResponse con Prestashop para poder usar todas las funcionalidad de Automatizaci贸n del primero.
Hay un m贸dulo de GetResponse para Prestashop que instal谩ndol, incluye muchas funcionalidades pero para usar la funci贸n "Ecommerce - URL Visitada" hay que insertar el siguiente c贸digo en el head.

<?php echo " <script type='text/javascript'>gaSetUserId('".$email."');</script>"; ?>

Por lo que he podido leer, este c贸digo solamente puede insertarse creando un m贸dulo. As铆 lo he hecho, lo instalo sin problemas, pero cuando voy a mi p谩gina, me sale el siguiente mensaje "No se ha encontrado ninguna plantilla para el m贸dulo getresponse2"

驴C贸mo puedo indicarle la ruta a mi archivo head.tpl?

Tampoco estoy seguro de estar cogiendo correctamente la variable $email.

Aqu铆 el c贸digo:

<?php
if (!defined('_PS_VERSION_'))
{
  exit;
}

class getresponse2 extends Module
{
  public function __construct()
  {
    $this->name = 'getresponse2';
    $this->tab = 'others';
    $this->version = '1.0.0';
    $this->author = '脕lvaro Portela';
    $this->need_instance = 0;
    $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
    $this->bootstrap = true;

    parent::__construct();

    $this->displayName = $this->l('GetResponse2');
    $this->description = $this->l('inserta c贸digo para GetResponse Ecommerce');

    $this->confirmUninstall = $this->l('驴Quieres desinstalar el m贸dulo?');

    if (!Configuration::get('MYMODULE_NAME'))
      $this->warning = $this->l('No name provided');
  }
    public function install()  
     {  
      if (parent::install() == false OR !$this->registerHook('header'))   
     return false;  
      return true;  
     }
    
    public function hookHeader($email)
     {
      global $smarty;
      // Variables o c贸digo PHP que queramos insertar
        echo " <script type='text/javascript'>gaSetUserId('".$email."');</script>";
       //echo " gaSetUserId('".$userEmail."');"; 
        $smarty->assign('email', $email);
      return $this->display(__FILE__, 'head.tpl');
     }
}

Muchas gracias por vuestra ayuda

Link to comment
Share on other sites

WTF????聽馃樀馃樀馃樀

Amigo mio te recominedo eches un ojo

https://devdocs.prestashop.com/

Prueba esto a ver si te funciona

getresponse2.php

class getresponse2 extends Module
{
  public function __construct()
  {
    $this->name = 'getresponse2';
    $this->tab = 'others';
    $this->version = '1.0.0';
    $this->author = '脕lvaro Portela';
    $this->need_instance = 0;
    $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
    $this->bootstrap = true;

    parent::__construct();

    $this->displayName = $this->l('GetResponse2');
    $this->description = $this->l('inserta c贸digo para GetResponse Ecommerce');

    $this->confirmUninstall = $this->l('驴Quieres desinstalar el m贸dulo?');

  }
    public function install()  
     {  
      if (parent::install() == false OR !$this->registerHook('header'))   
     return false;  
      return true;  
     }
    
    public function hookHeader($params)
     {
		if ($this->context->customer->email) {
			$this->context->smarty->assign('email', $this->context->customer->email);
      		return $this->display(__FILE__, 'head.tpl');
		}
     }
}

head.tpl

<script type='text/javascript'>gaSetUserId('{$email}');</script>

Lo que no me queda claro es d dnd pillas la funcion gaSetuserId ya q en el modulo no haces referecnia a ningun js o recurso externo.

Suerte

Edited by burrots
edit text (see edit history)
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...