Developer forum

Forum » Templates » Controlling behaviour of master pagetemlate (master.cshtml) Based on settings on a pagebased Item

Controlling behaviour of master pagetemlate (master.cshtml) Based on settings on a pagebased Item

Hans Ravnsfjall
Hans Ravnsfjall
Reply

Hi

I need a solution for where I can allow an editor to control things, that will effect behaviour of the master page template (master.cshtml) across all pages of all types.

I was considering setting up an item based page as a sort of a settings/controlPanel page. This item will eg hold a checkboc that the editor can check when a website is shut down because of eg.  maintanance. So the Idea is the editor can go in to the settings/controlPanel page, and activate maintenance mode, and thereby tell the master.cshml page not to render content, but instead show some sort of text like (the website is currently unavailable due to maintenance).

But my question is: Is there anyway of getting the values from fields of an itembased page "imported" into the master.cshtml page, and using the settings to define the behaviour of the master.cshml template?

I don´t presume that I can just use the RengerPageContent("PageId") to get the data/settings values into the master.cshtml template, and check the values of them here, and react to it? Or is this possible?

 

If not, does somebody have another suggetsion of achieving this, without having to set it up in website settings?

 

It has to be centrally controlled, and work across all itemtypes and pagetemplates, without goint into the website settings

 

Hopefully someone has some suggestions?

 

/Hans

 


Replies

 
Hans Ravnsfjall
Hans Ravnsfjall
Reply
 
Lars Larsen
Lars Larsen
Reply

Hi Hans

From your master template you can get the control panel item and react on values set in the item. You can use Dynamicweb.Services.Items.GetItem("ControlPanel", [itemid]) to get the control panel item.

 
Hans Ravnsfjall
Hans Ravnsfjall
Reply

Thank you Lars

How could i forget. Have used this exact feature in another scenario

Thanks for the help and reminding me 👍🏻

/Hans

 

You must be logged in to post in the forum