Problem with .AncestorsOrSelf(Level) and (doctype) in upgraded site
I've got some issues with a razor script I've written.
foreach (var page in @Model.AncestorsOrSelf(3)) { <p>@page.NodeTypeAlias</p> }
It seems to output pages that aren't at level 3. Is that me misunderstanding the .AncestorsOrSelf(level) or is it a problem with my site.
I also can't get to grips with .AncestorsOfSelf(doctypealias)
foreach (var page in @Model.AncestorsOrSelf("CountryHomepage")) { <p>@page.NodeTypeAlias</p> }
Is returning:
KnowledgeBaseChannel
How does that work! This is an umbraco instance that I've upgraded from 4.0.something to 4.7.2 this week and I'm transitioning the old xslt to razor. I need to get this live by end of Monday, please help.
@Model.AncestorsOrSelf("CountryHomepage") I dont think there's an overload for that, perhaps Model.AncestorsOrSelf.CountryHomepage works (but I would use the index if possible).
The meaning of AncestorsOrSelf is to return all ancestors + self. The integer overload I never tried: "A level filtered call .Method(int) - returns nodes which are <= or >= (depending on if you're using Ancestors or Descendants) the desired number" (see the link).
I use razor with legacy xlst schema on a few sites, cannot see why it should be a problem?
Problem with .AncestorsOrSelf(Level) and (doctype) in upgraded site
I've got some issues with a razor script I've written.
foreach (var page in @Model.AncestorsOrSelf(3))
{
<p>@page.NodeTypeAlias</p>
}
It seems to output pages that aren't at level 3. Is that me misunderstanding the .AncestorsOrSelf(level) or is it a problem with my site.
I also can't get to grips with .AncestorsOfSelf(doctypealias)
foreach (var page in @Model.AncestorsOrSelf("CountryHomepage"))
{
<p>@page.NodeTypeAlias</p>
}
Is returning:
KnowledgeBaseChannel
How does that work! This is an umbraco instance that I've upgraded from 4.0.something to 4.7.2 this week and I'm transitioning the old xslt to razor. I need to get this live by end of Monday, please help.
Razor doesn't work with the legacy xml so if you're still using that you need to change it to the new xml format.
Jeroen
Hi, I think you just need to remove that "s", AncestorOrSelf(3), see also http://umbraco.com/follow-us/blog-archive/2011/3/13/umbraco-razor-feature-walkthrough-part-5.aspx
@Model.AncestorsOrSelf("CountryHomepage") I dont think there's an overload for that, perhaps Model.AncestorsOrSelf.CountryHomepage works (but I would use the index if possible).
@Jeroen - Thanks I'd already thought about that, and set to new XML schema & republished
@Jonas - using AncestorOrSelf(3) works. But I don't understand the meaning of AncestorsOrSelf.
Good to hear it works. :)
The meaning of AncestorsOrSelf is to return all ancestors + self. The integer overload I never tried: "A level filtered call .Method(int) - returns nodes which are <= or >= (depending on if you're using Ancestors or Descendants) the desired number" (see the link).
I use razor with legacy xlst schema on a few sites, cannot see why it should be a problem?
is working on a reply...