Copied to clipboard

Flag this post as spam?

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


  • Hugh Loughrey 5 posts 46 karma points
    Jan 13, 2015 @ 04:22
    Hugh Loughrey
    0

    Query Document Types

    Hi apologise if this is a repost - I had a look and couldn't find what I was after.

    I want to run a query against my document types from my layout page to identify whether or not the current page is the home page...if so then do something...if not then donen't.

    The rough idea is something similar to the CurrentPage.HasValue("SomeValue") as outlined below:

            @if (CurrentPage.HasDocType("Home"))

            {

                @Html.Partial("umbFeatures", @Model.Content)

            }

    Can anyone offer any advice on how to go about this?

    Cheers

    Hugh

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jan 13, 2015 @ 05:39
    Jan Skovgaard
    100

    Hi Hugh and welcome to our :)

    You should be able to determine the documentype by writing

    if (@CurrentPage.DocumentTypeAlias == "Home"){
      //Your code here
    }
    

    Hope this helps.

    /Jan

  • Hugh Loughrey 5 posts 46 karma points
    Jan 13, 2015 @ 11:00
    Hugh Loughrey
    0

    Ah brilliant...thanks Jan! :)

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jan 13, 2015 @ 11:12
    Jan Skovgaard
    0

    Hi Hugh

    You're welcome, I'm happy to help :) Remember to keep the topic as solved if this works for you so others who may come across the same issue can quickly go to the solution.

    Cheers, Jan

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Jan 13, 2015 @ 12:05
    Jeroen Breuer
    0

    This documentation might also help: http://our.umbraco.org/documentation/Reference/Querying/

    Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft