Copied to clipboard

Flag this post as spam?

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


  • Jules 205 posts 448 karma points
    Nov 20, 2012 @ 10:13
    Jules
    0

    Model.DocumentType problem

    Just doing some Top Navigation. I have a property on the Home Page node called altNavigationName. I was using this in the following code to good effect

    string selected = Model.altNavigationName == "Home" ? " class=\"selected\"" : "";

    However I wanted to make the macro a little more generic so I thought if I test the model for the Home page docuemen type and pass that in as a Parameter that would work to

    var homePageDocType = string.IsNullOrEmpty(Parameter.homePageDocType) ? "" : Parameter.homePageDocType;
    string selected = Model.DocumentType == homePageDocType ? " class=\"selected\"" : "";

    However the selected variable always has a value of " class="selected"

    Can anybody explain what's going on? Am I missing something really simple?

    Jules

  • Fuji Kusaka 2203 posts 4220 karma points
    Nov 20, 2012 @ 10:46
    Fuji Kusaka
    0

    Hi Jules,

    Here is what you can do if 

    var homepage = Model.NodeById(1111);
    <li><a href="@homepage.Url" class="@Library.If(Model.Where("NodeTypeAlias == \"homePageDocType\""), "selected")">@homepage.Name</a></li>

     

    Not sure if this is what you are looking to achive though

    //fuji

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies