Copied to clipboard

Flag this post as spam?

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


  • S.Bhargava 33 karma points
    Mar 29, 2012 @ 17:09
    S.Bhargava
    0

    string is not recognized as valid boolean

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

    http://www.eyecatch.no/blog/2012/03/simple-navigation-macro-for-umbraco-5/

    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; }

     

    <ul>

    @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>

      }

    }

    </ul>

    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.Bhargava33 karma points
    Mar 29, 2012 @ 19:51
    S.Bhargava
    0

    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 

  • John Walker132 karma points
    Mar 29, 2012 @ 22:16
    John Walker
    0

    Hi,

    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.

     

    John

  • S.Bhargava33 karma points
    Mar 30, 2012 @ 06:44
    S.Bhargava
    0

    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;
         }
     }
      <ul>
      <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>
          }
      }
      </ul>
  • Michael Latouche613 karma points
    Mar 30, 2012 @ 09:59
    Michael Latouche
    0

    Hi,

    @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.

    Cheers,

    Michael.

  • S.Bhargava33 karma points
    Mar 30, 2012 @ 11:17
    S.Bhargava
    0

    Thanks for the help @Michael

  • Michael Latouche613 karma points
    Mar 30, 2012 @ 11:22
    Michael Latouche
    0

    You're welcome :-)

  • Tom738 karma points
    Apr 10, 2012 @ 10:09
    Tom
    0

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

     

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

Please Sign in or register to post replies

Write your reply to:

Draft
Our.umbraco.org is the community mothership for Umbraco, the open source asp.net cms. With a friendly forum for all your questions, a comprehensive documentation and a ton of packages from the community.