x First time here? Check out the FAQ
  • Avatar13posts33karma

    string is not recognized as valid boolean

    S.Bhargava started this topic March 29, 2012 @ 05:09, Go directly to the topic solution

    hi i have followed the following steps in creating navigation macro in umbraco 5.0.1 from the following website


    However i get an error at this point in the macro partial ----navigation code

    @inherits PartialViewMacroPage

    @using Umbraco.Cms.Web

    @using Umbraco.Cms.Web.Macros

    @using Umbraco.Framework


    @{ var source = string.IsNullOrEmpty(Model.MacroParameters.Source) ? Model.CurrentPage.Id : Model.MacroParameters.Source; }



    @foreach(var child in Umbraco.GetDynamicContentById(source).Children) {

      if (child.umbracoNaviHide != null && !bool.Parse(child.umbracoNaviHide)) {

        var activeClass = (Model.CurrentPage.Id == child.Id ? "active" : "");

        <li><a href="@child.NiceUrl" class="@activeClass"><span>@child.Name</span></a></li>




    at the time of debugging as string is not recognised as valid boolean type

    I am complete newbie and it wold be great if someone  solves my problem

  • S.Bhargava posted this reply March 29, 2012 @ 07:51

    I am sorry for my utterly bad explanation ....but can someone please guide me towards my goal to make a navigation bar in umbraco 5.0.

    This isnt solved.Sorry for the error caused 

  • Avatar34posts117karma
    Comment with ID: 112840
    John Walker posted this reply March 29, 2012 @ 10:16


    If you are using umbracoNaviHide in your foreach code you should just be able to do this:

    @foreach(var child in Umbraco.GetDynamicContentById(source).Children.Where("Visible")) {
    //code here 

    This will only select nodes which are visible. This is how it works in umbraco 4.7 anyhow I haven't built a site in v5 as yet so can't say I have tested it.



  • S.Bhargava posted this reply March 30, 2012 @ 06:44

    hi John thanks for coming up with a reply.The below code is in partial views ===> navigation.cshtml file.Can you please say how this

    @DynamicModel is taking the  content

    @inherits RenderViewPage
    @using Umbraco.Cms.Web;

         var Homepage = @DynamicModel;
         while (Homepage.ContentType.Alias != "homePage")
             Homepage = Homepage.Parent;
      <li><a href="@Homepage.Url">Home</a></li>
      @foreach (var item in Homepage.Children)
          if (@item.CurrentTemplate != null)
              var childName = item.Name ?? "(No name yet)";
              <li><a href="@item.Url">@childName </a></li>

  • Avatar455posts612karma
    Comment with ID: 112867
    Michael Latouche posted this reply March 30, 2012 @ 09:59


    @DynamicModel represents the current page you are processing. So, the first loop starts from the page being viewed and goes up in the tree hierarchy until it finds the actual homepage.

    I'm not sure if it works in 5.0, but in 4.7 you could also get there via @DynamicModel.AscendantsOrSelf("homePage"). Might be worth a try in 5.0 as well.



  • S.Bhargava posted this reply March 30, 2012 @ 11:17

    Thanks for the help @Michael

  • Avatar455posts612karma
    Comment with ID: 112884
    Michael Latouche posted this reply March 30, 2012 @ 11:22

    You're welcome :-)

  • Avatar580posts713karma
    Comment with ID: 113678
    Tom posted this reply April 10, 2012 @ 10:09

    rootNode.Children.Where("umbracoNaviHide != \"True\"").Any();


    Hi guys I'm trying this... any ideas why it isn't working in v5?

Please login or Sign up To post replies