Jump to content

Different product.tpl for same product


santi_cb

Recommended Posts

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

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.

  • Like 1
Link to comment
Share on other sites

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

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 by santi_cb (see edit history)
Link to comment
Share on other sites

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

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

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

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

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

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

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

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

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

 

12.31.2018-13.54.38

 

 

 

Edited by El Patron (see edit history)
Link to comment
Share on other sites

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

 

12.31.2018-13.54.38

 

 

 

Hi 

this is for 1.7 only or 1.6 too?

Link to comment
Share on other sites

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

  • 2 weeks later...

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