Copied to clipboard

Flag this post as spam?

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


  • Craig100 1078 posts 2366 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 11258 posts 23500 karma points MVP 7x 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 1078 posts 2366 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 11258 posts 23500 karma points MVP 7x 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

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies