Copied to clipboard

Flag this post as spam?

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


  • Bogdan 250 posts 427 karma points
    Feb 08, 2013 @ 10:42
    Bogdan
    0

    Umbraco 6 CurrentPage.NodeTypeAlias empty

    Hi,

    I'm trying to get the node type in an Umbraco 6 razor view but CurrentPage.NodeTypeAlias is empty. How can @if(CurrentPage.NodeTypeAlias ==  "Smth") { ... } be achieved?

    Thanks!

  • gary 385 posts 916 karma points
    Feb 08, 2013 @ 19:34
    gary
    101

    Hi

    Took a while to find this, but hope you have found it by now, if not;

    @if (CurrentPage.DocumentTypeAlias == "Smith") {}

    has worked.

    Regards G

     

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Feb 08, 2013 @ 19:59
    Dennis Aaen
    0

    Hi bfi,

    In razor, the currentPage can be a accessed by Model and CurrentModel should do the same, so I think something like this should work.

    @if(CurrentModel.NodeTypeAlias == "Smith"){}

    or

    @if(Model.NodeTypeAlias == "Smith"){}

    But as I mentioned, it should give the same result.

    Hope this will work for you.

    /Dennis

  • gary 385 posts 916 karma points
    Feb 08, 2013 @ 20:23
    gary
    1

    Hi

    Just to confirm - NodeTypeAlias seems to be no longer valid, don't know why, but just doesn't exist in either form in Mvc version. (According to Intellisense)

    So in Mvc version you have 

    @CurrentPage.DocumentTypeAlias or @Model.Content.DocumentTypeAlias

    @CurrentPage.DocumentTypeId or @Model.Content.DocumentTypeId

    have tested both and return what is required.

    Hope this helps everyone.

    G

  • Bogdan 250 posts 427 karma points
    Feb 09, 2013 @ 17:15
    Bogdan
    0

    Thanks a lot guys, I'll try DocumentTypeAlias as soon as I can :)

    Have a nice weekend!

  • Gordon 8 posts 28 karma points
    Feb 27, 2013 @ 01:35
    Gordon
    0

    Hi

    I have a simliar issue with properties changing when upgrading to umbraco 6

    This code below used to display the image, but does not display it anymore. I don't think it is anything to do with imagegen?

    I presume the GetProproperty has changed? Does anyone know what it should say?

    Thanks for your help

    Gordon Walker

    divclass="grid">

    @foreach (var item in @Model.Children)

    {

    var childName = item.Name ?? "(No name yet)";

    var include = Convert.ToBoolean(item.inWeeklyFloralMenu);

     

    if (include)

    {

    <divclass="order">

    <ahref="@item.Url">@childName</a>

    <p><ahref="@item.Url"><imgsrc="/ImageGen.ashx?image=@item.GetProperty("flowerPhoto") &width=220 &height=220"alt="flower photo"/></a></p>

    </div>

    }

    }

  • Bogdan 250 posts 427 karma points
    Feb 27, 2013 @ 14:14
    Bogdan
    0

    Hi Gordon,

    While I don't know what the problem is in your view (maybe missing .Value after GetProperty("flowerPhoto")?), I can say that I am getting images fine with something like @item.image (in your case @item.flowerPhoto) in my V6 site.

  • Gordon 8 posts 28 karma points
    Feb 27, 2013 @ 22:15
    Gordon
    0

    Thank you for that suggestion, It worked! The blogs did say Umbraco 6 was 99% compatable ... but another blog also said it is not as 'syntactically forgiving' as the previous version, so maybe it was always supposed to be GetPropertyValue

    Anyway, thanks again for your help

    Kind regards

    Gordon Walker

Please Sign in or register to post replies

Write your reply to:

Draft