hottern Posted April 20, 2013 Share Posted April 20, 2013 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 More sharing options...
hottern Posted April 20, 2013 Author Share Posted April 20, 2013 (edited) As I understand this can help $product_list = $smarty->fetch(_PS_THEME_DIR_.'product-list.tpl'); ? Edited April 20, 2013 by hottern (see edit history) Link to comment Share on other sites More sharing options...
Tung at RockPOS.com Posted April 20, 2013 Share Posted April 20, 2013 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 More sharing options...
hottern Posted April 20, 2013 Author Share Posted April 20, 2013 I can't change directory to product-list.tpl file from module? Link to comment Share on other sites More sharing options...
Tung at RockPOS.com Posted April 20, 2013 Share Posted April 20, 2013 Sorry, I don't understand your case. Change directory to product-list file? It sounds strange. Link to comment Share on other sites More sharing options...
hottern Posted April 20, 2013 Author Share Posted April 20, 2013 I need to modify view of product list in category Link to comment Share on other sites More sharing options...
hottern Posted April 20, 2013 Author Share Posted April 20, 2013 it should be lije here http://www.templatemonster.com/prestashop-themes.php Link to comment Share on other sites More sharing options...
Tung at RockPOS.com Posted April 20, 2013 Share Posted April 20, 2013 To modify view of product list in category, just go ahead and modify this file: /themes/[your-theme-name]/product-list.tpl Link to comment Share on other sites More sharing options...
hottern Posted April 20, 2013 Author Share Posted April 20, 2013 Oh, I know this) But I need to do this change in my new module. This is my task to made module that will do this changes Link to comment Share on other sites More sharing options...
Tung at RockPOS.com Posted April 21, 2013 Share Posted April 21, 2013 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 More sharing options...
hottern Posted April 22, 2013 Author Share Posted April 22, 2013 - 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now