Copied to clipboard

Flag this post as spam?

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


  • TomBowen 8 posts 51 karma points
    Mar 17, 2014 @ 17:34
    TomBowen
    0

    Problem with URLs

    I've only just recently started creating sites in Umbraco, but have run into an issue which I can't see posted anywhere (so apologies if this has).

    We have created a small site with mutliple root level nodes.

    Home
    Section 1
    Section 2
    Section 3

    Some of these sections have subpages

    Home
    Section 1
    ---SubPage 1
    ---SubPage 2
    Section 2
    ---SubPage 3
    Section3

    However, the URLs don't seem correct to us, we'd expect SubPage1 to have the URL:
    www.website.com/Section1/SubPage1

    But we're getting the URL
    www.website.com/SubPage1

    This is an issue (not only that the URLs don't make structural sense) because when we create pages in multiple Sections, but with the same page name, they get the same URL. The navigation on the website completely messes up, sending you to pages in other sections. Do we have a missing setting that is causing the URL to not include the folder structure?

  • Amir Khan 1282 posts 2739 karma points
    Mar 17, 2014 @ 18:48
    Amir Khan
    100

    Hi Tom,

    What you're experiencing shouldn't be happening. Can you post a screenshot of your node structure? Also, there are some advantages to setting things up like this instead of the way you have things:

    Content
    -Home
    --Section 1
    ---SubPage1
    ---Subpage2
    --Section 2

    Thanks,
    Amir

  • TomBowen 8 posts 51 karma points
    Mar 18, 2014 @ 11:14
    TomBowen
    0

    Sure no problem. We did think about having everything inside a Home node, but it helps our menu this way and so far we have had no downsides. I wouldn't have thought this URL issue would be related, would it?

    Here's the structure:
    http://i.imgur.com/nObng3R.png

    Here's the settings for one page (notice the URL):
    http://i.imgur.com/lOYuqWX.png

    Here's the settings for another page (same URL):
    http://i.imgur.com/kWNlbg7.png

  • TomBowen 8 posts 51 karma points
    Mar 18, 2014 @ 15:24
    TomBowen
    0

    It does appear to be because we have our sections as root level nodes. This means we're going to have to redesign our menu code, but at least the URLs are working now. A little annoying, but thank you for your answer.

  • Amir Khan 1282 posts 2739 karma points
    Mar 18, 2014 @ 15:54
    Amir Khan
    0

    From my experience, adding everything under a "home" node is great incase you want to add another site to the same installation, or add some kind of external content repository.

    Updating your menu code should be pretty straightforward. Feel free to post what you're using now to generate it if you need any help!

    Here's a starting point if you're using a partial to generate your nav.

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
    Layout = null;
    var home = Model.Content.AncestorOrSelf(1);
    }

    <ul>
    @*Render Home item*@

    @{ var homeActive = ""; }

    @if( home.Id == Model.Content.Id){
    homeActive = "active";
    }

    @*Render Home children*@
    @foreach (var item in home.Children.Where(x => x.IsVisible()))
    {
    var active = "";

    if(home.Id != Model.Content.Id ){ @* if NOT home *@
    if (item.Id == Model.Content.AncestorOrSelf(2).Id){
    @* if foreach id and currentpage ancestor id is equal *@
    active = "current";
    }
    }
    <li class="@active @item.IsLast("last")">
    <a href="@item.Url">
    @item.Name
    </a>
    @if (@item.Children.Where("umbracoNaviHide!= true").Count() >= 1)
    {
    <ul>
    @foreach(var subitem in @item.Children.Where("umbracoNaviHide!= true"))
    {
    <li><a href="@subitem.Url">@subitem.Name</a></li>
    }
    </ul>
    }

    </li>
    }
    </ul>
  • Ed Bishop 53 posts 203 karma points
    Mar 24, 2014 @ 09:43
    Ed Bishop
    0

    This has been an issue since v4, is there an actual fix for this rather than moving the content inside the root node as this doesn't fix the problem it just ignores it?

    Ed

  • Rik Helsen 670 posts 873 karma points
    Mar 25, 2014 @ 15:40
    Rik Helsen
    0

    It's a best practice to put everything nested in home nodes for many reasons. We even add a level to have a languageswitching page

    This way i can use xpath much more freely and within a language sensitive context (ie go to the homepage in the current language & list all children)

     

  • Rik Helsen 670 posts 873 karma points
    Mar 25, 2014 @ 15:43
    Rik Helsen
    1

    By the way, have you tried changing this setting in web.config?

        <add key="umbracoHideTopLevelNodeFromPath" value="False" />

  • Ed Bishop 53 posts 203 karma points
    Mar 25, 2014 @ 15:52
    Ed Bishop
    0

    It is only best practice given that you want to use Umbraco that way. 

    We have our content tree in the home node with all regular pages residing beneath on a site with many thousands of pages. We use the heirarchy to determine the layout of the site which allows us to create incredibly simple menu and navigation macros.

    We then have content which we want to sit outside of our regular structure, outside of our regular structure. This is very intuative as far as I am concerned and saves a great deal of overhead that would otherwise be required in the navigation and menu logic.

    Regardless of this, the system let's you do it either way so either way should work. A system functioning correctly should not rely on best practice, especially best practice that differs depending on who you speak to and is not written in a formal guide from the core team.

    I am not having a go at anyone who wants to use the system this way. Equally this is not a dig at the core team as they have plenty of work on there plate. I am merely pointing out that I should have to work around bugs just because I don't want to work this way.

  • Rik Helsen 670 posts 873 karma points
    Mar 25, 2014 @ 15:53
    Rik Helsen
    0

    And did you check that setting in your web.config?

  • Ed Bishop 53 posts 203 karma points
    Mar 25, 2014 @ 16:00
    Ed Bishop
    0

    Thanks Rik, I have just done that and it fixes the problem in our dev site.

    Only problem now is, this is a public sector site with thousands of visitors who bookmark places in the site etc so rolling out this change will probably annoy quite a few of them...

    Thanks again for your help.

    Ed

  • Rik Helsen 670 posts 873 karma points
    Mar 25, 2014 @ 16:03
    Rik Helsen
    0

    You're being quite dramatic about something that should have been foreseen during the design phase of the project ;)

    You could set up a number of rewrite rules to catch most of them, or create a smart 404 page using this Google snippet: https://support.google.com/webmasters/answer/136085

  • Nick LeFevre 2 posts 22 karma points
    Aug 13, 2014 @ 20:32
    Nick LeFevre
    0

    Ed,

    I'm glad you Mentioned this so succinctly:

    "This has been an issue since v4, is there an actual fix for this rather than moving the content inside the root node as this doesn't fix the problem it just ignores it?"

     

    Thanks,

    Nick

Please Sign in or register to post replies

Write your reply to:

Draft