Jump to content

Create module to change product-list view


hottern

Recommended Posts

Hi, I need to made module that will change product-list file from template to my product-list file from module folder so that when I'll choose category I will se modified product list. I already have my product-list file but don't know how to add it to template

Link to comment
Share on other sites

Hello,

Prestashop can automatically copy your files to overriding folder.

See this code snippet, it's from the class Module.

/**

* Install overrides files for the module

*

* @return bool

*/

public function installOverrides()

{

if (!is_dir($this->getLocalPath().'override'))

return true;

 

$result = true;

foreach (Tools::scandir($this->getLocalPath().'override', 'php', '', true) as $file)

{

$class = basename($file, '.php');

if (Autoload::getInstance()->getClassPath($class.'Core'))

$result &= $this->addOverride($class);

}

 

return $result;

}

 

So sorry to say, it helps you to move a overrided class (model or controller) only.

In your case, you have to modify the file in template folder manually.

Link to comment
Share on other sites

Hello,

It's impossible. See my previous reply to see how Module::install() works, it will copy only class or controller file to /override/ folder.

Anyway, there is an alternative option for you:

- You create a hook, for example, hookHeader or hookFooter,

- You create a new template file in your module, which will be called in the above hook

- You also add a js file or function which will be executed on (document).ready

- Now, by using Js commands and directly on browsers, remove DOM tree, and insert your modified template - which rendered and assigned to a js variable, or by calling an Ajax request

 

I know, it's quite complex, but it works. By this way, you have a packed module, modifying a core file is not required, it should make your module easier to install.

Link to comment
Share on other sites

- You also add a js file or function which will be executed on (document).ready

- Now, by using Js commands and directly on browsers, remove DOM tree, and insert your modified template - which rendered and assigned to a js variable, or by calling an Ajax request

I don't really know java script can you help me with this?

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