Dynamicweb 8 Documentation
ProductListTemplateExtender Class
Members  Example 

Product list template extender. Extends the rendering of a ProductCollection.
Object Model
ProductListTemplateExtender ClassOrder ClassProductCollection ClassProduct ClassExtranet Class
Syntax
'Declaration
 
Public MustInherit Class ProductListTemplateExtender 
   Inherits Dynamicweb.Extensibility.TemplateExtender
public abstract class ProductListTemplateExtender : Dynamicweb.Extensibility.TemplateExtender 
Example
Extending the product list templateExtending the product list template
using Dynamicweb.eCommerce.Products;

namespace Dynamicweb.Examples.CSharp.eCommerce
{
    public class ProductListTemplateExtenderSample : ProductListTemplateExtender
    {
        public override void ExtendTemplate(Dynamicweb.Rendering.Template template)
        {
            // Verify that User is logged in
            if (this.User == null || !this.User.LoggedIn)
                return;

            // Verify that Order is not complete
            if (this.Order == null || this.Order.Complete)
                return;

            // Set my custom template tag
            string tagContent;
            tagContent = this.ProductList.Count > 50 ? "You are showing more than 50 products on this page: {0}" : "You are showing less than 50 products on this page: {0}";
            template.SetTag("MyCustomModule.MyCustomTemplateTag", string.Format(tagContent, this.ProductList.Count));
        }
    }
}
Imports Dynamicweb.eCommerce.Products

Public Class ProductListTemplateExtenderSample
    Inherits ProductListTemplateExtender

    Public Overrides Sub ExtendTemplate(ByVal template As Rendering.Template)
        ' Verify that User is logged in
        If Me.User Is Nothing OrElse Not Me.User.LoggedIn Then
            Exit Sub
        End If

        ' Verify that Order is not complete
        If Me.Order Is Nothing OrElse Me.Order.Complete Then
            Exit Sub
        End If

        ' Set my custom template tag
        Dim tagContent As String
        If Me.ProductList.Count > 50 Then
            tagContent = "You are showing more than 50 products on this page: {0}"
        Else
            tagContent = "You are showing less than 50 products on this page: {0}"
        End If
        template.SetTag("MyCustomModule.MyCustomTemplateTag", String.Format(tagContent, Me.ProductList.Count))
    End Sub
End Class
Inheritance Hierarchy

System.Object
   Dynamicweb.Extensibility.TemplateExtender
      Dynamicweb.eCommerce.Products.ProductListTemplateExtender

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

ProductListTemplateExtender Members
Dynamicweb.eCommerce.Products Namespace

Send Feedback