Developer forum

Forum » CMS - Standard features » Override the page content type

Override the page content type

Thomas Larsen
Reply

Hi,

Is it possible to override the page content type by adding an extra parameter to the url?

The same way that it can be done with the Layout by adding a LayoutTemplate parameter

 

BR
Thomas


Replies

 
Nicolai Pedersen
Reply

Hi Thomas

You cannot. The earliest notification you can use for it, is this one - this should do the trick:

[Dynamicweb.Extensibility.Notifications.Subscribe(Dynamicweb.Notifications.Standard.Page.DeviceDetected)]
    public class DeviceDetectedObserver : Dynamicweb.Extensibility.Notifications.NotificationSubscriber
    {

        public override void OnNotify(string notification, Dynamicweb.Extensibility.Notifications.NotificationArgs args)
        {
            if (args == null)
            {
                return;
            }

            var loadedArgs = (Dynamicweb.Notifications.Standard.Page.DeviceDetectedArgs)args;
            if (!string.IsNullOrEmpty(Context.Current.Request.QueryString["contenttype"]))
            {
                var contentType = Context.Current.Request.QueryString["contenttype"];
                //validate content type
                loadedArgs.PageView.Redirect = false;
                loadedArgs.PageView.Page.ContentType = contentType;
            }
        }

    }

BR Nicolai

 

You must be logged in to post in the forum