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?
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
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.
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
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!
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
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.
or
But as I mentioned, it should give the same result.
Hope this will work for you.
/Dennis
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
Thanks a lot guys, I'll try DocumentTypeAlias as soon as I can :)
Have a nice weekend!
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>
}
}
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.
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
is working on a reply...