Page 1 of 1

Different Templates for 2 types of products

Posted: Tue Nov 06, 2012 2:46 pm
by limebot
I see the example in the documentation about changing templates but it really has no example for using different templates for products.

What I am looking to do is:
Product A use: template A
Product B use: template B

Also what value is the administration interface looking for when it calls for Template Display?
Is the Template Display value the name of the html file?

<bean class="org.broadleafcommerce.common.web.BroadleafThymeleafViewResolver">
...
<property name="fullPageLayout" value="layout/fullPageLayout" />
<property name="layoutMap">
<map>
<entry key="account/" value="layout/accountLayout" />
<entry key="catalog/" value="NONE" />
<entry key="product/" value="product/template_a" /> <---------example of what I am looking to do
<entry key="product/" value="product/template_b" /> <---------example of what I am looking to do
<entry key="checkout/" value="layout/checkoutLayout" />
<entry key="checkout/confirmation" value="layout/fullPageNoNavLayout" />
<entry key="layout/" value="NONE" />
</map>
</property>
</bean>


Any Ideas would be much appreciated!

Re: Different Templates for 2 types of products

Posted: Wed Nov 07, 2012 4:57 pm
by aazzolini
You're on the right track, but you need to be more granular about the request mappings that will resolve different templates.

For example, say I have two categories, one that maps to "tvs" and one at "monitors".

Then, I might have some products with URLs like "tvs/panasonic-gt30" and "monitors/dell-u2212hm".

Your mapping then might include

Code: Select all

<entry key="tvs" value="product/template_tv" />
<entry key="monitors" value="product/template_monitor" />

Re: Different Templates for 2 types of products

Posted: Thu Nov 08, 2012 11:54 am
by limebot
Thank you it is working perfectly!

Re: Different Templates for 2 types of products

Posted: Thu Oct 09, 2014 6:35 am
by frzferoz
Hi Limebot,
I just started to work on broadleaf,Can you send me code to add different templates for diff products

Re: Different Templates for 2 types of products

Posted: Tue Oct 28, 2014 12:42 am
by Anabia123
Hi Jay,

Can you elaborate on the steps? If I understand correctly you set the framework source and not the source for the demo correct? Cos the later happens when you setup the demo.

Now all the framework source is available as a jar file and I want them as a part of the source demo project so that I can change it. Let me know of your steps if you can.

Re: Different Templates for 2 types of products

Posted: Wed Nov 05, 2014 7:50 pm
by phillipuniverse
Rather than modifying the framework directly and adding all of the source into your project we recommend extending it instead. Think of Broadleaf as a set of libraries the same way that Spring is a set of libraries. Pulling down the Spring source code and modifying it for your project is never recommended nor is it recommended to do that with Broadleaf.

Just as a follow-up to the original post, Product now has a property for 'displayTemplate' that you can assign in the admin. This is a better way to do different templates per product.