Jump to content

Edit History

Shapes

Shapes

Well, after a lot of reading I tried to add my own module in themes/mytheme/modules.
I created a controller to extend ModuleFrontController : ajax.php in themes/mytheme/modules/ajaxproductrequest/controllers/front.

To keep it simple code looks like:

<?php 

class AjaxProductRequestAjaxModuleFrontController extends ModuleFrontController 
{ 
    public function __construct() 
    { 
        parent::__construct(); 
    } 
  
    public function initContent()
    {
        parent::initContent(); 
        return 'Hey!'; 
    } 
}

Now my ajax request in themes/custom.js looks like:

$.ajax({
    type: "POST",
    headers: { "cache-control": "no-cache" },
    url: "../../themes/mytheme/modules/ajaxproductrequest/controllers/front/ajax.php",
    data:     {
        ajax: 1,
        "token" : prestashop.token
    },
    success: function(result) {
        console.log(result);
    },
    error: function(result) {
        console.log(result);
    }
});

I also tried with url:

url: "{$link->getModuleLink('ajaxproductrequest','ajax')}"

Both lead me to the same result.
I got rid of the 404 error but now I'm stuck on an error:

Notice: Undefined index: tpl_dir

About that error, I read threads about a module compatibility error with Prestashop version, or a php version error but the module is now really simple as it is so I'm having a hard time understanding this error.

 

 

EDIT:

Looks like I got tis error appearing when switching debug mode on

Now

url: "{$link->getModuleLink('ajaxproductrequest','ajax')}"

leads to a 404 error.

And

url: "../../themes/mytheme/modules/ajaxproductrequest/controllers/front/ajax.php"

leads to a 500 error with no response details in console (which is why I turned debug mode on in the first place).

 

PS:

After some digging, Notice: Undefined index: tpl_dir came from:

<img class="" src="{$tpl_dir}../../img/p/{$image.id_image}/{$image.id_image}.jpg" alt="{$image.legend}" title="{$image.legend}" itemprop="image">

I fixed it using:

<img class="" src="{$urls.img_ps_url}p/{$image.id_image}/{$image.id_image}.jpg" alt="{$image.legend}" title="{$image.legend}" itemprop="image">

 

Shapes

Shapes

Well, after a lot of reading I tried to add my own module in themes/mytheme/modules.
I created a controller to extend ModuleFrontController : ajax.php in themes/mytheme/modules/ajaxproductrequest/controllers/front.

To keep it simple code looks like:

<?php 

class AjaxProductRequestAjaxModuleFrontController extends ModuleFrontController 
{ 
    public function __construct() 
    { 
        parent::__construct(); 
    } 
  
    public function initContent()
    {
        parent::initContent(); 
        return 'Hey!'; 
    } 
}

Now my ajax request in themes/custom.js looks like:

$.ajax({
    type: "POST",
    headers: { "cache-control": "no-cache" },
    url: "../../themes/mytheme/modules/ajaxproductrequest/controllers/front/ajax.php",
    data:     {
        ajax: 1,
        "token" : prestashop.token
    },
    success: function(result) {
        console.log(result);
    },
    error: function(result) {
        console.log(result);
    }
});

I also tried with url:

url: "{$link->getModuleLink('ajaxproductrequest','ajax')}"

Both lead me to the same result.
I got rid of the 404 error but now I'm stuck on an error:

Notice: Undefined index: tpl_dir

About that error, I read threads about a module compatibility error with Prestashop version, or a php version error but the module is now really simple as it is so I'm having a hard time understanding this error.

 

 

EDIT:

Looks like I got tis error appearing when switching debug mode on

Now

url: "{$link->getModuleLink('ajaxproductrequest','ajax')}"

leads to a 404 error.

And

url: "../../themes/mytheme/modules/ajaxproductrequest/controllers/front/ajax.php"

leads to a 500 error with no response details in console (which is why I turned debug mode on in the first place).

After some digging, Notice: Undefined index: tpl_dir came from:

<img class="" src="{$tpl_dir}../../img/p/{$image.id_image}/{$image.id_image}.jpg" alt="{$image.legend}" title="{$image.legend}" itemprop="image">

 

Shapes

Shapes

Well, after a lot of reading I tried to add my own module in themes/mytheme/modules.
I created a controller to extend ModuleFrontController : ajax.php in themes/mytheme/modules/ajaxproductrequest/controllers/front.

To keep it simple code looks like:

<?php 

class AjaxProductRequestAjaxModuleFrontController extends ModuleFrontController 
{ 
    public function __construct() 
    { 
        parent::__construct(); 
    } 
  
    public function initContent()
    {
        parent::initContent(); 
        return 'Hey!'; 
    } 
}

Now my ajax request in themes/custom.js looks like:

$.ajax({
    type: "POST",
    headers: { "cache-control": "no-cache" },
    url: "../../themes/mytheme/modules/ajaxproductrequest/controllers/front/ajax.php",
    data:     {
        ajax: 1,
        "token" : prestashop.token
    },
    success: function(result) {
        console.log(result);
    },
    error: function(result) {
        console.log(result);
    }
});

I also tried with url:

url: "{$link->getModuleLink('ajaxproductrequest','ajax')}"

Both lead me to the same result.
I got rid of the 404 error but now I'm stuck on a 500 error:

Notice: Undefined index: tpl_dir

About that error, I read threads about a module compatibility error with Prestashop version, or a php version error but the module is now really simple as it is so I'm having a hard time understanding this error.

 

 

EDIT:

Looks like I got tis error appearing when switching debug mode on

Now

url: "{$link->getModuleLink('ajaxproductrequest','ajax')}"

leads to a 404 error.

And

url: "../../themes/mytheme/modules/ajaxproductrequest/controllers/front/ajax.php"

leads to a 500 error with no response details in console (which is why I turned debug mode on in the first place).

After some digging, Notice: Undefined index: tpl_dir came from:

<img class="" src="{$tpl_dir}../../img/p/{$image.id_image}/{$image.id_image}.jpg" alt="{$image.legend}" title="{$image.legend}" itemprop="image">

 

Shapes

Shapes

Well, after a lot of reading I tried to add my own module in themes/mytheme/modules.
I created a controller to extend ModuleFrontController : ajax.php in themes/mytheme/modules/ajaxproductrequest/controllers/front.

To keep it simple code looks like:

<?php 

class AjaxProductRequestAjaxModuleFrontController extends ModuleFrontController 
{ 
    public function __construct() 
    { 
        parent::__construct(); 
    } 
  
    public function initContent()
    {
        parent::initContent(); 
        return 'Hey!'; 
    } 
}

Now my ajax request in themes/custom.js looks like:

$.ajax({
    type: "POST",
    headers: { "cache-control": "no-cache" },
    url: "../../themes/mytheme/modules/ajaxproductrequest/controllers/front/ajax.php",
    data:     {
        ajax: 1,
        "token" : prestashop.token
    },
    success: function(result) {
        console.log(result);
    },
    error: function(result) {
        console.log(result);
    }
});

I also tried with url:

url: "{$link->getModuleLink('ajaxproductrequest','ajax')}"

Both lead me to the same result.
I got rid of the 404 error but now I'm stuck on a 500 error:

Notice: Undefined index: tpl_dir

About that error, I read threads about a module compatibility error with Prestashop version, or a php version error but the module is now really simple as it is so I'm having a hard time understanding this error.

 

 

EDIT:

Looks like I got tis error appearing when switching debug mode on

Now

url: "{$link->getModuleLink('ajaxproductrequest','ajax')}"

leads to a 404 error.

And

url: "../../themes/mytheme/modules/ajaxproductrequest/controllers/front/ajax.php"

leads to a 500 error with no response details in console (which is why I turned debug mode on in the first place).

Shapes

Shapes

Well, after a lot of reading I tried to add my own module in themes/mytheme/modules.
I created a controller to extend ModuleFrontController : ajax.php in themes/mytheme/modules/ajaxproductrequest/controllers/front.

To keep it simple code looks like:

<?php 

class AjaxProductRequestAjaxModuleFrontController extends ModuleFrontController 
{ 
    public function __construct() 
    { 
        parent::__construct(); 
    } 
  
    public function initContent()
    {
        parent::initContent(); 
        return 'Hey!'; 
    } 
}

Now my ajax request in themes/custom.js looks like:

$.ajax({
    type: "POST",
    headers: { "cache-control": "no-cache" },
    url: "../../themes/mytheme/modules/ajaxproductrequest/controllers/front/ajax.php",
    data:     {
        ajax: 1,
        "token" : prestashop.token
    },
    success: function(result) {
        console.log(result);
    },
    error: function(result) {
        console.log(result);
    }
});

I also tried with url:

url: "{$link->getModuleLink('ajaxproductrequest','ajax')}"

Both lead me to the same result.
I got rid of the 404 error but now I'm stuck on a 500 error:

Notice: Undefined index: tpl_dir

About that error, I read threads about a module compatibility error with Prestashop version, or a php version error but the module is now really simple as it is so I'm having a hard time understanding this error.

 

EDIT:

Looks like I got tis error appearing when switching debug mode on

Shapes

Shapes

Well, after a lot of reading I tried to add my own module in themes/mytheme/modules.
I created a controller to extend ModuleFrontController : ajax.php in themes/mytheme/modules/ajaxproductrequest/controllers/front.

To keep it simple code looks like:

<?php 

class AjaxProductRequestAjaxModuleFrontController extends ModuleFrontController 
{ 
    public function __construct() 
    { 
        parent::__construct(); 
    } 
  
    public function initContent()
    {
        parent::initContent(); 
        return 'Hey!'; 
    } 
}

Now my ajax request in themes/custom.js looks like:

$.ajax({
    type: "POST",
    headers: { "cache-control": "no-cache" },
    url: "../../themes/mytheme/modules/ajaxproductrequest/controllers/front/ajax.php",
    data:     {
        ajax: 1,
        "token" : prestashop.token
    },
    success: function(result) {
        console.log(result);
    },
    error: function(result) {
        console.log(result);
    }
});

I also tried with url:

url: "{$link->getModuleLink('ajaxproductrequest','ajax')}"

Both lead me to the same result.
I got rid of the 404 error but now I'm stuck on a 500 error:

Notice: Undefined index: tpl_dir

About that error, I read threads about a module compatibility error with Prestashop version, or a php version error but the module is now really simple as it is so I'm having a hard time understanding this error.

Shapes

Shapes

Well, after a lot of reading I tried to add my own module in themes/mytheme/modules.
I created a controller to extend ModuleFrontController : ajax.php in themes/mytheme/modules/ajaxproductrequest/controllers/front.

To keep it simple code looks like:

<?php 

class AjaxProductRequestAjaxModuleFrontController extends ModuleFrontController 
{ 
    public function __construct() 
    { 
        parent::__construct(); 
    } 
  
    public function initContent()
    {
        parent::initContent(); 
        return 'Hey!'; 
    } 
}

Now my ajax request in themes/custom.js looks like:

$.ajax({
    type: "POST",
    headers: { "cache-control": "no-cache" },
    url: "../../themes/mytheme/modules/ajaxproductrequest/controllers/front/ajax.php",
    data:     {
        ajax: 1,
        "token" : prestashop.token
    },
    success: function(result) {
        console.log(result);
    },
    error: function(result) {
        console.log(result);
    }
});

I also tried with url:

url: "{$link->getModuleLink('ajaxproductrequest','ajax')}"

Both lead me to the same result.
I got rid of the 404 error but now I'm stuck on a 500 error:

Notice: Undefined index: tpl_dir

About that error, I read threads about a module compatibility error with Prestashop version, or a php version error but the module is now really simple as it is so I'm having a hrad time understanding this error.

×
×
  • Create New...