santi_cb Posted December 19, 2018 Share Posted December 19, 2018 Hi everybody, i need some help with this. What i need it to have 2 different product.tpl but for the same product, that means, have the original product.tpl (with the url /{category}/{rewrite}) and have other (rxproduct.tpl with the url /rx/{rewrite}} I try to duplicate the productcontroller and change the name adding the new rxproduct.tpl but with no luck Any ideas? regards! Link to comment Share on other sites More sharing options...
joseantgv Posted December 20, 2018 Share Posted December 20, 2018 2 hours ago, ArnoldBB said: What will be the rx? it will also be a category? Because with the url /{category}/{rewrite} it will go to Productcontroller by default but for other one (url/rx/{rewrite}), it will depend on rx. That's a good point. First check if both URLs execute your modification in ProductController. 1 Link to comment Share on other sites More sharing options...
santi_cb Posted December 20, 2018 Author Share Posted December 20, 2018 18 hours ago, santi_cb said: Hi everybody, i need some help with this. What i need it to have 2 different product.tpl but for the same product, that means, have the original product.tpl (with the url /{category}/{rewrite}) and have other (rxproduct.tpl with the url /rx/{rewrite}} I try to duplicate the productcontroller and change the name adding the new rxproduct.tpl but with no luck Any ideas? regards! Hi, thanks for yourreply. rx it is not a category, it is only part of the url, the point is to have 2 different views for the same product, but changing the URL, the "standard" one and the other with the new url. That is why i thought in duplicating the productcontroller Thanks regards! Link to comment Share on other sites More sharing options...
musicmaster Posted December 20, 2018 Share Posted December 20, 2018 It evades me why you want to have two different controllers. Can't you have some conditional code inside your controller: "if(condition) load product.tpl else load productrx.tpl"? Link to comment Share on other sites More sharing options...
santi_cb Posted December 20, 2018 Author Share Posted December 20, 2018 (edited) 2 hours ago, musicmaster said: It evades me why you want to have two different controllers. Can't you have some conditional code inside your controller: "if(condition) load product.tpl else load productrx.tpl"? Let me try to explain. It is difficult to understand or explain. Using an if condition (i think ) it is not possible because i want to sell exactly the same product in prestashop, the only difference is the "front part". Ex: In the standard tpl i would like to sell only the product A and in the rx i would like to sell the product A + accesories, i think this is impossible to do with if conditions but any help is apreciated regards Edited December 20, 2018 by santi_cb (see edit history) Link to comment Share on other sites More sharing options...
santi_cb Posted December 20, 2018 Author Share Posted December 20, 2018 21 minutes ago, ArnoldBB said: In which version of prestashop you want this change? Because the work flow is different for both 1.6 and 1.7 version. Where is location of this rx product? Like if we are in category page the url will (url/{category}/{rewrite}). So where will be this rx url(url/rx/{rewrite})? You are right it will be like creating the new controller like product controller and assigning the product that new controller. But you have to first try to do with product controller only. I am in 1.6. You are right, url(url/rx/{rewrite} this is exactly what i need. As i told in my previous message i want to show the product in the standard tpl an add a "button" to call this rxcontroller that shows the product A in the rxproduct.tpl hope you can help me Regards!! Link to comment Share on other sites More sharing options...
santi_cb Posted December 20, 2018 Author Share Posted December 20, 2018 I was able to develop a new module using the productcontroller, but i don't know how to add the new url rule in order to get it properly and use the new tpl Any help? thanks regards Link to comment Share on other sites More sharing options...
musicmaster Posted December 20, 2018 Share Posted December 20, 2018 You can provide modules with arguments. But why should you? As long as the module knows what it should do it can provide different interfaces with the same url. Link to comment Share on other sites More sharing options...
santi_cb Posted December 21, 2018 Author Share Posted December 21, 2018 Yes i know. That is what I need to redifine the productcontroller, leave it exactly but with other url when I call it any help best regards Link to comment Share on other sites More sharing options...
santi_cb Posted December 21, 2018 Author Share Posted December 21, 2018 I use http://nemops.com/creating-new-pages-in-prestashop/#.XBymblxKiUm for the module Link to comment Share on other sites More sharing options...
joseantgv Posted December 22, 2018 Share Posted December 22, 2018 You don't need a new controller. You have to edit ProductController and define a different template depending on the URL. Link to comment Share on other sites More sharing options...
santi_cb Posted December 23, 2018 Author Share Posted December 23, 2018 Could you help me with that or how to start with it ? Thanks in advance Regards Link to comment Share on other sites More sharing options...
joseantgv Posted December 25, 2018 Share Posted December 25, 2018 On 12/23/2018 at 7:50 PM, santi_cb said: Could you help me with that or how to start with it ? Thanks in advance Regards I don't know which is your level, which is your problem or where are you stuck, but you could start here: https://devdocs.prestashop.com/1.7/modules/concepts/overrides/ Link to comment Share on other sites More sharing options...
santi_cb Posted December 25, 2018 Author Share Posted December 25, 2018 5 hours ago, joseantgv said: I don't know which is your level, which is your problem or where are you stuck, but you could start here: https://devdocs.prestashop.com/1.7/modules/concepts/overrides/ Thanks! I read it and I know those ideas. The problem is that, I am not able to link the idea URL ROUTING - template in the ProductController, if you could give the part I should edit ... Thanks in advance mery Christmas Link to comment Share on other sites More sharing options...
joseantgv Posted December 26, 2018 Share Posted December 26, 2018 On 12/25/2018 at 8:56 AM, santi_cb said: Thanks! I read it and I know those ideas. The problem is that, I am not able to link the idea URL ROUTING - template in the ProductController, if you could give the part I should edit ... Thanks in advance mery Christmas Is this enough? https://stackoverflow.com/questions/7118823/check-if-url-has-certain-string-with-php Link to comment Share on other sites More sharing options...
santi_cb Posted December 26, 2018 Author Share Posted December 26, 2018 18 minutes ago, joseantgv said: Is this enough? https://stackoverflow.com/questions/7118823/check-if-url-has-certain-string-with-php Hi! Not at all, could you tell me in the productcontroller in 1.6 which part I should re-program, I can’t find the part... sorry best regards Link to comment Share on other sites More sharing options...
joseantgv Posted December 26, 2018 Share Posted December 26, 2018 9 minutes ago, santi_cb said: Hi! Not at all, could you tell me in the productcontroller in 1.6 which part I should re-program, I can’t find the part... sorry best regards You should do the modification where it assigns the template. Link to comment Share on other sites More sharing options...
santi_cb Posted December 26, 2018 Author Share Posted December 26, 2018 4 minutes ago, joseantgv said: You should do the modification where it assigns the template. Yes, but the product controller assigns the url according to SEO preference (in the controller url canonical....) but I don’t know how to assign the url that the controller could check and show the rxproduct.tpl instead of product.tpl Link to comment Share on other sites More sharing options...
joseantgv Posted December 30, 2018 Share Posted December 30, 2018 On 12/26/2018 at 9:11 PM, santi_cb said: Yes, but the product controller assigns the url according to SEO preference (in the controller url canonical....) but I don’t know how to assign the url that the controller could check and show the rxproduct.tpl instead of product.tpl But how do you want to assign a different URL? And under which criteria? Link to comment Share on other sites More sharing options...
santi_cb Posted December 31, 2018 Author Share Posted December 31, 2018 9 hours ago, joseantgv said: But how do you want to assign a different URL? And under which criteria? I just want to change the view of the same product. This is why I think is better to develop a simple module just to override ProductController url part and template part just to provide this kind of url http://xxxx.com/module/rx + id_product i know how to modify the template part of the controller but I don’t know how to modify the url part. I develop this module using the productcontroller whiout modifying anything and writing in the url bar the url with id_product i was redirecting to the SEO url structure for the products thanks in advance best regards Link to comment Share on other sites More sharing options...
musicmaster Posted December 31, 2018 Share Posted December 31, 2018 It evades me what you are doing with the url structure. That is totally handled in .htaccess. It is quite simple to modify or override the function initContent() in /controllers/front/productController.php. At its bottom it says $this->setTemplate(_PS_THEME_DIR_.'product.tpl'); You can change that to something like: if($this->product->id == "123") $this->setTemplate(_PS_THEME_DIR_.'product2.tpl'); else $this->setTemplate(_PS_THEME_DIR_.'product.tpl'); Link to comment Share on other sites More sharing options...
santi_cb Posted December 31, 2018 Author Share Posted December 31, 2018 8 minutes ago, musicmaster said: It evades me what you are doing with the url structure. That is totally handled in .htaccess. It is quite simple to modify or override the function initContent() in /controllers/front/productController.php. At its bottom it says $this->setTemplate(_PS_THEME_DIR_.'product.tpl'); You can change that to something like: if($this->product->id == "123") $this->setTemplate(_PS_THEME_DIR_.'product2.tpl'); else $this->setTemplate(_PS_THEME_DIR_.'product.tpl'); This I know how to do it, the point is how to use this 2 different .tpl for the same product 123 based on the URL this is why I think I need i productcontroller2 on the module Link to comment Share on other sites More sharing options...
musicmaster Posted December 31, 2018 Share Posted December 31, 2018 2 minutes ago, santi_cb said: This I know how to do it, the point is how to use this 2 different .tpl for the same product 123 based on the URL this is why I think I need i productcontroller2 on the module You keep talking vaguely. Make it concrete.How should those urls look like? Link to comment Share on other sites More sharing options...
santi_cb Posted December 31, 2018 Author Share Posted December 31, 2018 2 minutes ago, musicmaster said: You keep talking vaguely. Make it concrete.How should those urls look like? I would like to have a module that provide me a url. Http://xxxxxx.com/RX/id_product And with this show me other tpl for the product RX is the module name Link to comment Share on other sites More sharing options...
PrestaHeroes USA Posted December 31, 2018 Share Posted December 31, 2018 (edited) to change the presented consider template inheritance. this allows a dev to add/change/delete template content. I did not read everything above http://build.prestashop.com/news/starter-theme-news/#template-inheritance more about: Parent/Child Theme Feature In PrestaShop 1.7 http://build.prestashop.com/news/Child-Themes-Feature/ with template inheritance anything can be modified without jumping through a bunch of hoops Edited December 31, 2018 by El Patron (see edit history) Link to comment Share on other sites More sharing options...
santi_cb Posted December 31, 2018 Author Share Posted December 31, 2018 7 minutes ago, El Patron said: to change the presented consider template inheritance. this allows a dev to add/change/delete template content. I did not read everything above http://build.prestashop.com/news/starter-theme-news/#template-inheritance more about: Parent/Child Theme Feature In PrestaShop 1.7 http://build.prestashop.com/news/Child-Themes-Feature/ with template inheritance anything can be modified without jumping through a bunch of hoops Hi this is for 1.7 only or 1.6 too? Link to comment Share on other sites More sharing options...
PrestaHeroes USA Posted December 31, 2018 Share Posted December 31, 2018 1.7 only, you did not mention in your original post ps version so I made assumption. if you are doing for 1.6...you should post in job section, I"m sure you could get a very affordable price from the young guns..... template inheritance makes it significantly easier to change front office content... 1.6, we would have left PS if they had not included template inheritance in 1.7 lol Link to comment Share on other sites More sharing options...
santi_cb Posted January 10, 2019 Author Share Posted January 10, 2019 Any help here, I tried to find any solution best regards 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