Design and CSS styles
Version 7.x > Design and CSS styles > Change Master Page Images according to the child page View modes: 
User avatar
Certified Developer 13
Certified Developer 13
saxena.sanket1-gmail - 1/29/2014 10:39:12 AM
   
Change Master Page Images according to the child page
Hello,

I have created a master page which consist of Banner Image and I want to change that banner according to the child page selected.

Ex: for Home page- Banner1.jpg, For AboutUS- Banner2.jpg and so on.

NOTE: The page design is in the hierarchy: Banner Then Menus Then Child Content Then Footer

And the master Page included the Banner ,Menu and Footer.

Suggestion Please. (Try to avoid Jquery)

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 1/29/2014 6:22:17 PM
   
RE:Change Master Page Images according to the child page
Hello,

The easiest way to achieve this will be to use the K# macros and e.g. if-else conditions.
K# syntax

you can use this macro to get the current document name:
{%CurrentPageInfo.DocumentName%}

Best Regards,
Martin Danko

User avatar
Certified Developer 13
Certified Developer 13
saxena.sanket1-gmail - 1/30/2014 11:37:08 AM
   
RE:Change Master Page Images according to the child page
Have applied
{%if(CMSContext.CurrentPageInfo.DocumentName== "About"){"Yes"}else{"No"} %} 

User avatar
Certified Developer 10
Certified Developer 10
josha-bpstudios - 1/30/2014 3:45:59 PM
   
RE:Change Master Page Images according to the child page
Where are you placing this statement? In a transformation? Web Part?

Also, try putting {return "Yes"}else{return "No"}

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 1/30/2014 8:36:47 PM
   
RE:Change Master Page Images according to the child page
Hello,

The macro example I've sent you is supposed to be used in the Visibility condition of the web part, so it seems that you are using it directly on the page?

Best Regards,
Martin Danko

User avatar
Certified Developer 13
Certified Developer 13
saxena.sanket1-gmail - 2/21/2014 1:10:10 PM
   
RE:Change Master Page Images according to the child page

Yes martin i was using on the page anyways i got the solution:
The below code work on the layout of master page.

<script runat="server">
protected override void OnPreRender(EventArgs e)
{
string pName= CMSContext.CurrentPageInfo.DocumentName;
if(pName== "About")
{
//About us image here
}
else if(pName=="News and Events")
{
// News Image here
}
......and so on
</script>