Copied to clipboard

Flag this post as spam?

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


  • Tony Groome 261 posts 804 karma points
    Feb 03, 2015 @ 17:55
    Tony Groome
    0

    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>

    }

    }

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Feb 03, 2015 @ 18:02
    Jeroen Breuer
    0

    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

  • Tony Groome 261 posts 804 karma points
    Feb 03, 2015 @ 18:11
    Tony Groome
    0

    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

  • Tony Groome 261 posts 804 karma points
    Feb 03, 2015 @ 18:31
    Tony Groome
    0

     

     

     

     

     

    I'm trying to get the Read More just like on the right hand side...

     

     

     

     

Please Sign in or register to post replies

Write your reply to:

Draft