First off I'm completely new to the world of Umbraco, and still trying to figure things out. I'm using it as a platform to learn Razor/C#, while building my portfolio.
My issue:
On my "homePage" i have a loop of "portfolioCase" i'm successfully looping a title, image, and a description from "portfolioCase". But i can't figure out how to pull the url of "portfolioCase" so that i can link to the page from the loop.
Content nodes (pages) use the IPublishedContent interface as the model (see more here) for published content. The model has a Url property you can use, e.g.:
// To be used in the "portfolio" template
@foreach (var caseItem in Model.Children)
{
<a href="@caseItem.Url">@caseItem.Name</a>
}
@{ var List = Model.Descendants().Where(x => x.ContentType.Alias=="portfolioCase");}
@foreach(var child in List){
<a "href="@child.Url">Show case</a>
}
Get url of document type
First off I'm completely new to the world of Umbraco, and still trying to figure things out. I'm using it as a platform to learn Razor/C#, while building my portfolio.
My issue: On my "homePage" i have a loop of "portfolioCase" i'm successfully looping a title, image, and a description from "portfolioCase". But i can't figure out how to pull the url of "portfolioCase" so that i can link to the page from the loop.
This is my Content tree:
Best Regards
Thomas
Hi Thomas,
Content nodes (pages) use the
IPublishedContent
interface as the model (see more here) for published content. The model has aUrl
property you can use, e.g.:Thanks Morten. I'll take a look at the documentation.
Do i need to use Model.Descendant if i use it on "homePage" template?
I ended up just using @child.Url
is working on a reply...