About this article

Written by:
Posted:
06/07/2010 17:16:00

About the author

Imar Spaanjaars is the owner of De Vier Koeden, a company specializing in consultancy and development on the Microsoft .NET platform and DynamicWeb.

Interested in custom development or consultancy on DynamicWeb or .NET? Then contact De Vier Koeden through the Contact page.

If you want to find out more about Imar Spaanjaars, check out his About page on this web site or check out his personal website.

Quick Tips - Custom Modules - Changing the Page Title

NOTE: the concepts presented in this article are now considered obsolete possibly because better alternatives are available.

In an earlier article I showed you how to override the page title using a NotificationSubscriber. This is convenient if you have the need to change the title for all or many pages in your site. However, when building custom modules, you may have the need to change the title for a specific page only. Fortunately, this is very easy to do in a custom module.

The ContentModule class, the base class for all your custom modules, has a Pageview property of type PageView (note the inconsistency in capitalization, something you need to be aware of when using C#). This PageView property in turn has a Meta property that lets you set the page title through its Title property.

To set the page title in your custom module, you can use the following code:

[AddInName("YourModuleName")]
public class Frontend : ContentModule
{
  public override string GetContent()
  {
    // Other code here to create HTML
    Pageview.Meta.Title = "Your custom page title here";
    
    // Other code here to return the HTML
  }
}

When rendered in the browser, your page title ends up between the <title> tags in the <head> section of your page.

By clicking 'Accept All' you consent that we may collect information about you for various purposes, including: Statistics and Marketing