CurrentPage is dynamic and doesn't have intellisense. I prefer Model.Content which is strongly typed. For example Model.Content.GetPropertyValue<string>("summary"). To use GetPropertyValue<> you need the Umbraco.Web namespace.
I have another block of code like that which finds me images. So then I fill in 2 columns, one column has the image and the other column has the name and summary. That's all fine. I then have a Read More which I need to span across the bottom of the 2 columns. So far I can only get it to span across one column. the url for the Read Me button is taken from the inner loop like @summary. So I figured if I could get the url outside of the loop I could set up another column and sit the Read Me button where I want it. I hope my ramblings make sense!!
Looping problem
Hi All
Is there some way I can get @summary and @page.Name from my loops outside the loops? I feel like I'm going around the loops!!
Thanks
Tony
@foreach(var page in CurrentPage.Children)
{
foreach(var apage in page.Children.Reverse().Take(1)
{
summary = apage.summary;
<span style="line-height: 1.4em; font-size: 16px; font-weight: bold;">@page.Name</span>
<p>@summary</p>
}
}
Hmm what are you trying to do?
Doesn't CurrentPage.summary just work?
CurrentPage is dynamic and doesn't have intellisense. I prefer Model.Content which is strongly typed. For example Model.Content.GetPropertyValue<string>("summary"). To use GetPropertyValue<> you need the Umbraco.Web namespace.
Jeroen
Hi Jeroen
I have another block of code like that which finds me images. So then I fill in 2 columns, one column has the image and the other column has the name and summary. That's all fine. I then have a Read More which I need to span across the bottom of the 2 columns. So far I can only get it to span across one column. the url for the Read Me button is taken from the inner loop like @summary. So I figured if I could get the url outside of the loop I could set up another column and sit the Read Me button where I want it. I hope my ramblings make sense!!
Tony
I'm trying to get the Read More just like on the right hand side...
is working on a reply...