Copied to clipboard

Flag this post as spam?

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


  • Craig100 1136 posts 2523 karma points c-trib
    Feb 07, 2015 @ 13:41
    Craig100
    0

    How to determine what doctype you're on

    Umb7.2.1

    If you have a base page that needs to programatically set a div container around the @RenderBody() section if it's not the home page, how do you determine the docType of the page you're displaying? There's nothing sensible coming up in intellisense and I can't find anything useful on line or in the Umbraco documentation.

    Thnx

    Craig

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 07, 2015 @ 15:38
    Jan Skovgaard
    100

    Hi Craig

    If you're using the dynamic version then you should be able to use this

    @if(currentPageNode.DocumentTypeAlias == "YourDocTypeAlias"){
      <div class="special-div">
         @RenderBody()
       </div>
    } else{
         @RenderBody()
    }
    

    Does this work for you?

    /Jan

  • Craig100 1136 posts 2523 karma points c-trib
    Feb 07, 2015 @ 16:07
    Craig100
    1

    This is a surprise I deleted this thread 5 mins after I posted it.

    I try not to use dynamics if poss. I sorted it with:-

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        @* To control wrapping main content in container tags if not home page *@
        bool showContainer = false;
        if(Model.Content.DocumentTypeAlias == "HomePage"){
            showContainer = true;
        }
    }

    As it was the base tempate, it didn't have the @inherits line in it, which was why intellisense wasn't working.

    What's now more interesting is why this thread didn't get deleted.

    Cheers,

    Craig

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 07, 2015 @ 19:24
    Jan Skovgaard
    0

    Hi Craig

    That's really weird - Not sure why the post did not delete properly then but good to see you found a solution when using strongly typed :)

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft