Copied to clipboard

Flag this post as spam?

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


  • Gerry Smith 13 posts 73 karma points
    Dec 10, 2015 @ 18:31
    Gerry Smith
    0

    7.3.1 Problem with CurrentPage.Children

    Consider this code:

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    @{ 
        var pages = @CurrentPage.Children; 
    }
    
      <table style="width:100% !important">
        <thead>
        <tr>
          <td>Subbasin Name</td>
          <td style="width: 15% !important">Hydrologic Unit Code (HUC)</td>
          <td style="width: 25% !important">TMDL Status</td>
          <td style="width: 25% !important">Implementation Plan Status</td>
          <td style="width: 15% !important">Five Year Review Status</td>
        </tr>
        </thead>
        <tbody>
        @foreach (var page in @pages){
          <tr>
            <td><a href="@page.URL">@page.pageTitle</a> <br />@page.watershedName</td>
            <td>@page.hydrologicUnitCode</td>
            <td>@page.tmdlStatus</td>
            <td>@page.implementationPlanStatus</td>
            <td>@page.fiveYearReviewStatus</td>
           </tr>
        }
        </tbody>
      </table>
    

    Problem: The table draws and populates as desired but for one thing...

    <a href="@page.URL">@page.pageTitle</a>
    

    The URL of each of the child pages isn't right.. each row of the table has the right Title, and the other columns are correct, but the anchor is being formed with the URL of the CurrentPage rather than each Child's .Url. I assume I am doing something wrong, but I cannot see why this isn't working.

    Any suggestions?

    Thanks! Gerry

  • Kevin Jump 2343 posts 14890 karma points MVP 8x c-trib
    Dec 10, 2015 @ 19:24
    Kevin Jump
    100

    hi

    i think URL is case sensitive so it should be @page.Url ?

  • Ian 178 posts 752 karma points
    Dec 10, 2015 @ 19:30
    Ian
    0

    Hi I suspect that if you look at the html source of the page the href of the link will be empty which is why when you click on the link it looks as if the url of the current page has been inserted into the view.

    However the problem is that page.URL has not returned anything as it should be page.Url, the CamelCase makes a difference. Could be a typo but here's a reference of default iPublishedContent properties just in case.

    https://our.umbraco.org/documentation/reference/querying/IPublishedContent/Properties

  • Gerry Smith 13 posts 73 karma points
    Dec 10, 2015 @ 19:32
    Gerry Smith
    0

    sigh Yes, you're right Kevin. I feel pretty dumb right now.

    Thank you as well to Ian. I knew it was camel case but apparently I am not on my game today.

Please Sign in or register to post replies

Write your reply to:

Draft