Here are some example code to explain my need. I need to extend the productlisttemplate with a special tag and call the getColors with the current productid. I there a way to do this?
public class ExtendColorsToProductListTemplate : ProductListTemplateExtender
{
public override void ExtendTemplate(Dynamicweb.Templatev2.Template template)
{
template.SetTag("Colors", getColors(?));
}
private string getColors(string productId)
{
//Based on some logic and the product id for the current product in the list, I need to get som information here......
}
}
Developer forum
E-mail notifications
How do I get the productid in a ProductListTemplateExtender?
Kim Søjborg Pedersen
Posted on 08/11/2011 15:38:00
Replies
Morten Bengtson
Posted on 08/11/2011 15:56:18
I'm not sure I understand what you need.
If you need to extend the rendering of each product in your product list, you should use a ProductTemplateExtender.
If you actually need to extend the rendering of a separate product list on the same page as your current product, then you can get the ProductID from the querystring with Dynamicweb.Base.Request("ProductID")
BR.
Morten
If you need to extend the rendering of each product in your product list, you should use a ProductTemplateExtender.
If you actually need to extend the rendering of a separate product list on the same page as your current product, then you can get the ProductID from the querystring with Dynamicweb.Base.Request("ProductID")
BR.
Morten
Kim Søjborg Pedersen
Posted on 08/11/2011 17:05:26
It is the productlist I want to extend with my tag, so I think the ProductListTemplateExtender must be the one.
I try to explain it more clealy.
Im on a page with a groupid in the querystring. On the page all products in that group is listed. Foreach of the products I want to extend with my own tag. The content of that custom tag is specific for each of those products and thats why i need the productid.
I try to explain it more clealy.
Im on a page with a groupid in the querystring. On the page all products in that group is listed. Foreach of the products I want to extend with my own tag. The content of that custom tag is specific for each of those products and thats why i need the productid.
Morten Bengtson
Posted on 08/11/2011 17:22:01
Foreach of the products I want to extend with my own tag
Then I think you need to use a ProductTemplateExtender - it will be called for each product in the list.
It is a template extender for products (in whatever template they are rendered). It is not an extender only for the product details template.
Kim Søjborg Pedersen
Posted on 08/11/2011 17:32:58
Okay thank you for that, but I still need a way to get the productid?
Morten Bengtson
Posted on 08/11/2011 17:35:33
This post has been marked as an answer
Try this...
public override void ExtendTemplate(Dynamicweb.Templatev2.Template template) { template.SetTag("Colors", getColors(Product.ID)); } private string getColors(string productId) { //Based on some logic and the product id for the current product in the list, I need to get som information here...... }
Votes for this answer: 0
You must be logged in to post in the forum