Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > One masterpage, but different template content depending on page? View modes: 
User avatar
Member
Member
mvcftw-gmail - 5/22/2013 1:32:49 PM
   
One masterpage, but different template content depending on page?
I have this problem with my master page where some pages need a CSS rule to behave one way, and some pages need a class rule to behave another way.
<div class="Content">
[ page place holder ]
</div>

For example, some pages want .Content to have a fixed width, and others do not. It's too late to move this down to the page level, so I'm trying to fix it on the master page for the time being but my knowledge of Kentico is too little at this point.

If Kentico wasn't in the picture, I might add a class to the body tag, something like <body class="<%=PageName%>" and then I could target the template classes differently on a page by page basis to style the rule the way I need it.

If Kentico wasn't in the picture, I might slap an if statement around the problem something like:
<% if X then %>
<div class="X Content">
<% else %>
<div class="Y Content">
<% end if %>
[ page place holder ]
</div>

There are lots of possibilites, but I'm not sure how to do anything like this in Kentico.

Any insight is appreciated. In the mean time, I'll experiment with jQuery adding the body class I guess.

User avatar
Member
Member
eagleag - 5/22/2013 2:03:42 PM
   
RE:One masterpage, but different template content depending on page?
1) you could add CSS (stylesheet) webpart to master page and control its visibility using macros.
for each page that you watn to add specific css rules, you would add a wepart.

2) this cold be done in kentico using macros (K#):
<% if X then %>
<div class="X Content">
<% else %>
<div class="Y Content">
<% end if %>
[ page place holder ]
</div>

User avatar
Certified Developer 13
Certified Developer 13
kentico-jx2tech - 5/22/2013 2:26:52 PM
   
RE:One masterpage, but different template content depending on page?
I have been using the HTML Tag Code web part on the master page and putting the following in the Html Tag Code property:
id="node-{%CurrentDocument.NodeGUID %}"

it will add the pages NodeGUID as the id and the template GUID as a class to the HTML element like...
<html xmlns="http://www.w3.org/1999/xhtml" 
id="node-d4181cd0-3926-4466-a27c-899ca7a0b08a"
class="template-b7fbd99c-2eec-49a3-9fa6-c1e9ea5f6ed0">

User avatar
Certified Developer 8
Certified Developer 8
Petr Dvorak - 5/22/2013 3:08:02 PM
   
RE:One masterpage, but different template content depending on page?
1. You can extend the default Page (menu item) document type with a custom field such as "MenuItemBodyClass" and than use it in the code:
<div class="Content <%=ValidationHelper.GetString(CMSContext.CurrentDocument.GetValue("MenuItemBodyClass"), string.Empty)%>">
Or you can use some of the existing properties (which are not really useful), such as CMSContext.CurrentDocument.DocumentMenuClassHighlighted (can be set up on Properties tab / Navigation)

However you need to enter your desired CSS class to each and every document which should have it.


2. You can use some login and change the CSS class of <body> during preRender:
CMS.CMSHelper.CMSContext.CurrentBodyClass += " fullWidthPage";

3. You can use "Head HTML Code" webpart to embed custom CSS rules into the <head> section.