ASPX templates
Version 6.x > ASPX templates > Editable content in footer and header in master page (ASPX templates) View modes: 
User avatar
Member
Member
Wolfworks - 1/2/2012 3:42:12 PM
   
Editable content in footer and header in master page (ASPX templates)
Hi,

Starting my first ventures in Kentico: I would like to know what the recommended way is to display editable content in the footer and header of the master page of an ASPX templated website. I have been searching the help files and Google extensively, but can't find the solution.

To elaborate on the matter: the footer and header must contain some content which the content editors themselves can edit. It must be in the master page, every page must have the same data. I don't want a CMSEditableRegion on the master page, because then every page can have different footers/headers.

The demo Corporate website contains an Editable Image web part, which is only editable in the Corporate Website node (the template), but I fail to reproduce the functionality. I can see there is an import of the web part in "App_Data\Templates\CorporateSite\Data\Documents\cms_document.xml.export", but it it not available as a web part zone in the Root.master. That master page can be edited in the "Edit template properties", and has an extra layout tab. My master page hasn't got a layout tab.

The closest I could find, was [url=http://devnet.kentico.com/Forums/f19/t4287/Problems-with-CMSEditableImage-amp;-CMSEditabl.aspx]http://devnet.kentico.com/Forums/f19/t4287/Problems-with-CMSEditableImage-amp;-CMSEditabl.aspx[/url], but I am curious if there isn't a better way.

To finish: yes, I know I can use the portal engine, but am more accustomed to .NET development and feel more at ease using CSS, HTML, c# and general ASP.NET.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 1/3/2012 1:57:14 AM
   
RE:Editable content in footer and header in master page (ASPX templates)
Hi,

If I am getting the right meaning, all the editable regions should have the same content, right? In this case, somewhere must be the content added - the best way would be on the master page template. Then in ASPX development model you ened to use the code below in the code behind of the page template to get the content from the parent document's editable region:

MainContentText2.LoadContent(CMS.PortalEngine.PageInfoProvider.GetPageInfo(CMSContext.CurrentSiteName, "/", "en-us", null, true, CMS.DataEngine.ConnectionHelper.GetConnection()));


You will need to replace MainContentText2 with real ID of your editable region control.

Best regards,
Juraj Ondrus

User avatar
Member
Member
Wolfworks - 1/3/2012 4:24:32 AM
   
RE:Editable content in footer and header in master page (ASPX templates)
Hi Juraj,

Thanks for your reply.. That is also a solution, I already saw it on http://devnet.kentico.com/Forums/f47/fp10/t17203/Global-Editable-Region.aspx.

However, when using a CMSEditableRegion in a master page, it is visible on all pages using that master page. And can be edited and saved, I assume. The CMSEditableRegion is not a must: if there is an alternative, I would like to use that.

The example of the demo Corporate website contains an Image, which can be edited only in the master page. Is this something that can be accomplished within the ASPX templates as well? That would be the nicest solution: only editable in the master page, and nowhere else.

Summarizing: I prefer a solution where the content is edited in one place (edit mode) and displayed on all other pages. Like a proper master page solution. If nothing else is available, I think I will go for the solution kbonnett provided (http://devnet.kentico.com/Forums/f19/t4287/Problems-with-CMSEditableImage-amp;-CMSEditabl.aspx): the content is nicely separated, editable only once and displayed on the other pages via the master page.

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 1/3/2012 6:53:35 AM
   
RE:Editable content in footer and header in master page (ASPX templates)
Hello,


1. You can get a content of editable region from the master page by code and display it by a Literal control for example (it is an HTML code) on the child documents.

2. You can use the mentioned approach and disable the Editable region on the child documents by code so it won't be editable.

3. You can change the saving of Editable region on the child documents and save the content to the master page by a custom code. Then you will be able to edit the content from the master page and from the child documents as well.

These links can be helpful for you:
http://devnet.kentico.com/Forums.aspx?forumid=13&threadid=1098
Adding content to the Editable region


Best regards,
Helena Grulichova


User avatar
Member
Member
Wolfworks - 1/4/2012 6:33:19 AM
   
RE:Editable content in footer and header in master page (ASPX templates)
Hi Helena,

Thanks for pointing out the options. Apparently I am not missing an obviously standard function in the CMS.

My solution to the problem is still the way kbonnett suggested, I like the way it separates the content from all other pages, and the way it enables re-use of content:
1) Created a document type Information, with a Name and Description, where the Name is linked as the Document Name and can only be created in CMS.Folder objects.
2) Added a folder which is not shown in navigation, containing "generic information".
3) Added the following code to the code behind of the master page (FooterContentLeft and FooterContentRight are Literal controls):

protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
FooterLeftContent.Text = GetInformation("FooterLinks");
FooterRightContent.Text = GetInformation("FooterRechts");
}

private string GetInformation(string pageName)
{
var content = TreeHelper.GetDocument(CMSContext.CurrentSiteName, "/Algemene-informatie/" + pageName, "nl-NL", true, "Wolfworks.Information", false);

if (content != null)
{
object value;
content.TryGetValue("Beschrijving", out value);

if (value != null)
{
return value.ToString();
}
}
return string.Empty;
}


When required, I can refactor the GetInformation function to a helper class or extension method, and build some extra caching in it.. But for now, it works.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 1/5/2012 1:46:14 AM
   
RE:Editable content in footer and header in master page (ASPX templates)
Hi,

Have you tried the Static text or HTML text web parts - they are editable only on the Design tab so, standard editor won't be able to edit them.

Or, using just repeater - create some fake document where you will have the header and footer texts and then display these texts using two repeaters - one in header and another in footer.

Best regards,
Juraj Ondrus