Copied to clipboard

Flag this post as spam?

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


  • Brenton Mumford 19 posts 40 karma points
    Apr 01, 2013 @ 23:59
    Brenton Mumford
    0

    @Library.NiceUrl not working like it used to? 4.7.1 to 4.7.1.1

    I have two installations of Umbraco. One is 4.7.1, the other is 4.7.1.1.

    On the former, the following snippet works great for creating a 'utility' menu on a 'setup' node. It allows me (or someone else) to edit this running utility menu without having to touch a template.

    @inherits umbraco.MacroEngines.DynamicNodeContext
    @{
      var topnode = Model.AncestorOrSelf(1);
      <ul class="inlineMenu">
        <li><a href="@library.NiceUrl(topnode.selectTermsAndConditionsNode)">@topnode.termsAndConditionsText</a></li>
        <li><a href="@library.NiceUrl(topnode.selectDisclaimerNode)">@topnode.disclaimerText</a></li>
        <li><a href="@library.NiceUrl(topnode.selectPrivacyNode)">@topnode.privacyText</a></li>
        <li><a href="@library.NiceUrl(topnode.selectNoticeOfPrivacyPracticesNode)">@topnode.noticeOfPrivacyText</a></li>  
      </ul>
    }

    This same structure does not work on my new installation. I've isolated each portion of the string, and it seems to be choking on the @library.NiceUrl portion, in that I can return the ID of the node fine, but when I attempt to return a niceurl, it errors out. When I put it in the template, I get "Error loading MacroEngine script (file: Top-Utility-Menu.cshtml)"

    Anything jump out to anyone? Thanks for reading!

  • gary 385 posts 916 karma points
    Apr 02, 2013 @ 00:05
    gary
    0

    Hi Brenton

    Off of the top of my head, have you allowed friendly url's in the config?

    G

  • Fuji Kusaka 2203 posts 4220 karma points
    Apr 02, 2013 @ 09:38
    Fuji Kusaka
    0

    Not sure why but you could do something like

    @foreach(dynamic topnode in Model.AncestorOrSelf(1).Descendants("docType")){
                            <li><a href="@topnode.Url @umbraco.library.NiceUrl(topnode.Id) ">@topnode.Name</a></li>
                            }
                           
  • Brenton Mumford 19 posts 40 karma points
    Apr 04, 2013 @ 17:18
    Brenton Mumford
    0

    Folks,

    @gary - I'm not totally sure how to allow friendly urls in the config - I didn't see a switch for that anywhere.

    @fuji - I don't think I want to just run through all the items on the doctype, since I've set up what amounts to an entire 'setup' node that feeds various bits of information to various spots throughout the sites - footers, images for banners, etc. Although that response may not make sense, in that I may have misunderstood what it was you were showing me. :)

    I've had the same issue with the same razor on a 4.7 installation running on localhost. I simply packaged up the site and installed it on this other server, and this script is a failpoint. Makes me think there's something wrong with my syntax, but I'm just not good enough with razor to know what it might be. I tried to keep it ultra simple ...

  • gary 385 posts 916 karma points
    Apr 04, 2013 @ 19:24
    gary
    0

    Hi Brenton

    Apologies, used the Umbraco terminology, here is the bit you need to check in the web.config

      <appSettings>

          <add key="umbracoUseDirectoryUrls" value="true" />

          </appSettings>

    Should be around line 38 if using Visual Studio, if your document reads "false" it will not understand the NiceUrl part as it will be looking for a .aspx extension on the page.

    Have a look at that first, if that isn't the answer, then we can have a look at the code.

    Hope it helps

    G

     

     

     

     

     

  • Brenton Mumford 19 posts 40 karma points
    Apr 04, 2013 @ 19:45
    Brenton Mumford
    0

    @gary - I stared at that node for a few minutes, wondering if that's what you meant, but didn't want to change it on a production server unless I knew it was the right choice. 

    In any case, altering that doesn't make any difference on either of my broken installations, and the server on which that code DOES work has it set to false, too:

        <add key="umbracoUseDirectoryUrls" value="false" />

    So that's perplexing.

  • gary 385 posts 916 karma points
    Apr 04, 2013 @ 20:04
    gary
    0

    Hi Brenton

    Yes, stranger than fiction - had a similar issue the other day with a line I hadn't changed in the config, but everything worked as it should. Put it down to so many improvements in Umbraco that it was a positive. 

    Ok, there was an issue surrounding your AncestorOrSelf call, somewhere, can't remember where in updates, it broke 

    Try AncestorsOrSelf(1), that has always been OK. ie use plural Ancestors, just add the s

    If you are just going up to the parent node in your tree, you can use Model.Up(1).

    Try that one see if makes a difference

    G

Please Sign in or register to post replies

Write your reply to:

Draft