About this article
Written by: | Imar Spaanjaars |
Posted: | 7/19/2010 5:15 PM |
Page views: | 4850 |
Rate this article
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.
Follow Imar on Twitter if you want to be notified of new articles in this Dynamicweb series.
Quick Tips - Custom Modules - Changing the Page Title
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.