Jump to content

Load Smarty & Database


gheaeckkseqrz

Recommended Posts

Hello,

 

I'm developing a clothing e-shop.

I'm making a module to filter product by color / size / categories ...

I'd like to have it working via Ajax.

 

I need t load smarty & the database classe in my Ajax target .php file.

How can I do that ?

 

Regards,

Pierre.

Link to comment
Share on other sites

You can just include the following at the start of your file:

 

<?php
include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/../../init.php');
include(dirname(__FILE__).'/yourmodule.php');

$module = new YourModule();
echo $module->yourAjaxHandler();

 

That will load up all the Prestashop goodness in your script, and also then allow you to place the actual ajax call function within your module (from where you can access the facilities you need). You can also use Tools:getValue('post_or_get_variable') if you need to pass parameters.

 

This is exactly how the blocklayered module works btw and that would be a good source of "inspiration" ;)

Edited by Paul C (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...