Copied to clipboard

Flag this post as spam?

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


  • Richard Terris 273 posts 715 karma points
    Nov 26, 2012 @ 13:39
    Richard Terris
    0

    Umbraco 4.11 using MVC

    Maybe I'm being stupid here, but hopefully someone can help..

    I have a partial view for navigation and the <li> elements are built in razor like so:

    @foreach (var page in Model.Content.AncestorOrSelf().Children.Where(x => x.GetProperty("showInNavigation")))
     {
            <li>
                <a href="@page.NiceUrl()" title="@page.Name">@page.GetProperty("pageTitle").Value</a>
            </li>
        }

    I'm being told that GetProperty does not take 1 argument, but when I examine the definition for GetProperty it does take a string

    IPublishedContentProperty GetProperty(string alias);

    Since I'm using a Lambda expression, the above should equate to true.

    Is this an issue with 4.11 or MVC support? Or am I doing something stupid?

    I know I can use x.IsVisible but I'm just messing around with the MVC support and I can imagine giving the user more control as to whether they want to show something in a menu, as we often have sites with different sub-menus

  • Richard Terris 273 posts 715 karma points
    Nov 26, 2012 @ 13:54
    Richard Terris
    0

     @foreach (var page in Model.Content.AncestorOrSelf().Children.Where(x => x.GetProperty("showInNavigation").Value == "1"))

        {

            <li>

                <a href="@page.NiceUrl()" title="@page.Name">@page.GetProperty("pageTitle").Value</a>

            </li>

        }

    This stops the error but doesn't show all pages

  • Stephen Davidson 216 posts 392 karma points
    Nov 26, 2012 @ 13:55
    Stephen Davidson
    0

    I'm no expert but is it not the case that the show in navigation is numeric (if you are using a checkbox like with navihide), either a 1 or a 0 so if you want to use it as a string it needs to be made one?

    Can i ask why you are using x =>?

    S

  • Richard Terris 273 posts 715 karma points
    Nov 26, 2012 @ 13:56
    Richard Terris
    0

    Well done!

    I assumed because I was reading it from XML (umbraco.config) it WAS treated as a string.

    .ToString() worked a treat - thanks!

  • Stephen Davidson 216 posts 392 karma points
    Nov 26, 2012 @ 14:00
    Stephen Davidson
    1

    Glad to help somone else after years if being helped...

Please Sign in or register to post replies

Write your reply to:

Draft