Copied to clipboard

Flag this post as spam?

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


  • Phil Young 19 posts 39 karma points
    Apr 30, 2012 @ 18:27
    Phil Young
    0

    get property?

    Back again,

    I'm simply trying to get a property but cant get it to work from what little documentation there seems to be available.

    <ul id="navigation">
        @{    
            @* Get the current node, then walk up the tree from the current page to get the root node *@
            var currentPage = DynamicModel;
            var homePage = DynamicModel.AncestorsOrSelf.Last();
    
        }
    
        <li @(homePage.Id == currentPage.Id ? "class=active" : "")><a href="@homePage.Url" title="@homePage.Name">@homePage.Name</a></li>
    
        @foreach(var childPage in homePage.Children)
        {
            @childPage.GetProperty("pageTitle").Value
            string docType = childPage.NodeTypeAlias;
            switch(docType)
            {
                case "standard":
                    <li @(((childPage.Id == currentPage.Id) || (childPage.Id == currentPage.AncestorsOrSelf.FirstOrDefault().Id)) ? "class=active" : "")><a href="@childPage.Url" title="@childPage.Name">@childPage.Name</a></li>
                    break;
                case "contact":
                    <li>contact</li>
                    break;
                case "work":
                    <li>work</li>
                    break;
                default:
                    <li @(((childPage.Id == currentPage.Id) || (childPage.Id == currentPage.AncestorsOrSelf.FirstOrDefault().Id)) ? "class=active" : "")><a href="@childPage.Url" title="@childPage.Name">@childPage.Name</a></li>
                    break;
            }
    </ul>

    Whilst inside the loop, I simply want to check the value of a particular property using this:

    @childPage.GetProperty("pageTitle").Value

    but I get the YSOD.

    Any help?

    Is there any way to list all the properties of a node as you used to be able to do with xslt? Feels like you have to work blind with this stuff otherwise.

    Ta.

Please Sign in or register to post replies

Write your reply to:

Draft