Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Anders 13 posts 133 karma points
    May 29, 2017 @ 17:17
    Anders
    0

    Remove header attribute on some pages

    Hi :)

    I have a header tag in my basetemplate:

    <header id="header" class="alt">

    And I only wan't it to have the class attribute class="alt" on the frontpage. So all the other pages that use the same basetemplate should have: <header id="header">

    I can hardcode it, but is there a smart way to do this in Umbraco?

    Thanks in advance

  • Ben 108 posts 374 karma points
    Jun 01, 2017 @ 18:54
    Ben
    100

    If you are using MVC I think you could do something like this in the template:

    @{ 
      string sHeaderClass = "";
    
      if(CurrentPage.Level == 1){
        sHeaderClass = "alt";
      }
      else{
      sHeaderClass = "";
      }
    
      <header id="header" class="@sHeaderClass">
    }
    
  • Anders 13 posts 133 karma points
    Jun 02, 2017 @ 12:25
    Anders
    0

    Worked perfectly !

    Thanks @Ben

  • Ben 108 posts 374 karma points
    Jun 02, 2017 @ 12:30
    Ben
    0

    Your welcome Anders, glad I could help!

Please Sign in or register to post replies

Write your reply to:

Draft