Copied to clipboard

Flag this post as spam?

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


  • Deci 19 posts 48 karma points
    Sep 14, 2011 @ 13:26
    Deci
    0

    NiceUrl on the homepage

    Greetings, 

    I have this piece of test code that loops from the current page's ancestors and creates list output..you can probably guess what for. When I run this code and it gets to the home page, NiceURL puts in a hash (pound symbol) (#) instead of the single forward slash.

    If I breakpoint on the last line of code here, the value of n.NiceURL will initially be '#' and if I wait a few seconds it will change to '/' and that's what gets assigned. Even if I break higher up but then let the code continue, it doesn't get those few seconds to change from hash to slash and assigns a hash.

     while (n.Parent != null)
                {
                    n = (Node) n.Parent;
                    crumbs.Add(string.Format("<li><a href=\"{0}\">{1}</a></li>", n.Url, n.Name));
                }

    I get around it by using n.Url instead but has anyone else seen this sort of behaviour on NiceUrl and what causes it?

    Thanks

  • David Verberckmoes 46 posts 77 karma points
    Sep 16, 2011 @ 11:51
    David Verberckmoes
    0

    Hi Deci,

    What version of umbraco are you running?

    Do you see the "#" in the properties tab on your rootnode in the umbraco backend? Then it might help to save and publish the node or do a "republish entire site" on the "content" treeitem.

    Rgds,

    David

  • Deci 19 posts 48 karma points
    Sep 16, 2011 @ 12:31
    Deci
    0

    Hi David, 

    I am running 4.7.0

    The backend for this rootnode doesn't have a '#' anywhere and the 'Link to document' is '/'.

    It's very strange how it initially responds with the hash but given time will revert to the slash. I can of course republish but for this particular problem I am working around it by using .Url instead which always seems to have the correct value.

    thanks for the reply,

    Deci

  • shanem 39 posts 93 karma points
    Feb 07, 2013 @ 17:00
    shanem
    0

    I ran into this issue today and had to revert to using Url instead of NiceUrl. The weird thing is NiceUrl works fine in other pages for the same node. I'm using 4.11.1.

    Any resolution to this or is it a bug?

  • gary 385 posts 916 karma points
    Feb 07, 2013 @ 19:42
    gary
    0

    Hi Guys

    I have had this issue too in V6 using NIceUrl, but just went back to the development site and cannot reproduce it. At the time I saw it I was developing the the mobile code and had a half written piece of code for a pop-up (# placeholder) and put it down to that, so pretty much ignored it.

    All I can really add is that it is not there now, having gone backward, forward, up, down, in and out of mobile, but still could not reproduce it.

    Regards

    G

  • gary 385 posts 916 karma points
    Feb 18, 2013 @ 18:10
    gary
    0

    Quick update on this - came across a page where it occurs;

    The page conatins javascript, jquerymobile, and assorted stuff - but eliminating eveything piece by piece I found the cause.

           @foreach ( dynamic d in CurrentPage.gallery)

    If I block out everything else on the page the hash appears at the end of the url with this line of code in the file.
    It would take someone far more knowledgeable than myself to offer a reason why, so maybe someone can?
    Regards G
  • Andreas Iseli 150 posts 427 karma points
    Feb 18, 2013 @ 21:30
    Andreas Iseli
    0

    It seems that this is one reason why NiceUrl is obsolete und future versions. Just wanted to share my thoughts about it.

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Feb 19, 2013 @ 09:22
    Jeroen Breuer
    0

    This blog might have some nice tips for the home url: http://cultiv.nl/blog/2010/12/19/tip-of-the-week-the-ultimate-site-structure-setup/

    Jeroen

  • gary 385 posts 916 karma points
    Feb 19, 2013 @ 10:40
    gary
    0

    Further update

    The #  occurs at the end of the url on another page. So by commenting out code and refreshing, eliminated it, then refreshed the page again and it returned.

    Continued to refresh the page and it appreared and disappeared randomly, the number of refreshes to re-appear was written down as follows;

    8, 2, 4, 14, 5, 1, 1, 5, 6. I hope this is sufficient to say that it is a "random" event - but can anyone think of a suggestion as to why it may be happening, it does not seem to be affected by any code or call, just appears and disappears?

    G

  • gary 385 posts 916 karma points
    Feb 22, 2013 @ 13:24
    gary
    0

    Hi Guys

    I think I have solved this, at the same time as solving another issue. My knowlwdge of the internal workings of Umbraco are limited, so I will just state what I have found in the hope that someone can explain.

        var pages = CurrentPage.AncestorOrSelf("top").Children.Where("DocumentTypeAlias == \"Whatever\"").OrderBy("CreateDate desc");

    worked in previous versions, but in V6 running MVC, it appears that anything afer the Children is ignored, but what it does do is randomly add a # to the url. As if the additional code is flagging an error, by adding the #, or being directed somewhere?
    How do I know this? 
    var pages = CurrentPageAncestorOrSelf("top").Children.
    @foreach ( var item in pages.Where("DocumentTypeAlias == \"Whatever\"").OrderBy("CreateDate desc"))
    { @item.Url() }
    returns exactly as it should, in the right order and there is no longer # in the url.
    This has taken a lot of "trying" with the dynamic CurrentPage to find this, have left out the other cases, so I hope that by posting it can help others.
    As I said, I cannot explain it and will not even try - but if someone who can could post a reply - I'm sure it would be appreciated by many in the future.
    Regards G

     

  • gary 385 posts 916 karma points
    Mar 04, 2013 @ 10:03
    gary
    0

    Hi

    Quick update on this, the # is nothing to do with Umbraco - it is from the Mvc side. According to the forums, it occurs when you have jQuery mobile installed or alternatively you are using any ajax calls. So, why some of us may have thought it was to do with NiceUrl, Url, in fact it is the ahref wrapped around it.

    By adding data-ajax="false" to the reference, it should remove it. 

    But then again, we have all been wrong before.

    regards G

Please Sign in or register to post replies

Write your reply to:

Draft