Table of Contents

Class PageTemplateExtender

Namespace
Dynamicweb.Frontend
Assembly
Dynamicweb.dll

Pageview template extender. Extends the rendering of a PageView.

public abstract class PageTemplateExtender : TemplateExtender
Inheritance
PageTemplateExtender
Derived
Inherited Members

Examples

using System;
using Dynamicweb.Content;
using Dynamicweb.Frontend;

namespace Dynamicweb.Examples;

public class PageTemplateExtenderSample : PageTemplateExtender
{
    public override void ExtendTemplate(Dynamicweb.Rendering.Template template)
    {
        ArgumentNullException.ThrowIfNull(template, nameof(template));

        template.SetTag("MyTag", "MyValue");

        //Find the page in the master language and loop its language versions
        Page? myHomePage = Services.Pages.GetPage(1);
        if (myHomePage is null)
            return;

        PageView? pageView = PageView.Current();
        if (pageView is null)
            return;

        foreach (var languageVersionsOfHomePage in myHomePage.Languages)
        {
            //If one of the language versions of the page matches the current area, use the id and name for a link or something.
            if (languageVersionsOfHomePage.AreaId == pageView.AreaID)
            {
                string? name = languageVersionsOfHomePage.MenuText;
                int id = languageVersionsOfHomePage.ID;
            }
        }

        //Using navigation tags, see http://doc.dynamicweb.com/documentation-9/content/content/pages#3241, to get a language context based page
        var myLanguageContextHomePage = Services.Pages.GetPageByNavigationTag(pageView.AreaID, "MyHomePage");
    }
}

Properties

PageView

Gets or sets the PageView instance.

public PageView? PageView { get; set; }

Property Value

PageView

The pageview.

To top