Folder homepage url

Topics: General
Jul 1, 2011 at 12:34 AM
Edited Jul 1, 2011 at 12:35 AM


I would like to place subfolder 'homepages' within their associated folder, rather than within the parent folder. For example, the contact section homepage within this tree:

|- News       /news.html
|- About      /about.html
|- Contact    /contact/index.html   <--
   |- FAQ     /contact/faq.html

Compared to what seems to be the natural structure within Composite:

|- News        /news.html
|- About       /about.html
|- Contact     /contact.html        <--
   |- FAQ      /contact/faq.html

Is there a good way to achieve the former structure? We are moving an existing site with a structure like this and would like to keep the links the same if possible.

Jul 1, 2011 at 1:17 AM

There are major changes to the URL behavior in the current beta / next release - here the URL's could look like

|- News        /news
|- About       /about
|- Contact     /contact       <--
   |- FAQ      /contact/faq

More info about the coming URL features and formatting - note that you should be able to upgrade to this release when it become available, so you can start the site building now and then get the new features when available.
Jul 1, 2011 at 4:52 PM

Great thanks mawtex. Is there any idea yet of a timescale for the new release?

Jul 1, 2011 at 6:00 PM

Even with the new url system coming you won't be able to achieve what you're asking for here. You basically wan't urls for pages with childrens to be threated specially by this logic

   if (page.HasChildren)
      return page.Url.Remove(".html") + /"index.html"
      return page.Url

and the reverse logic has to be applied on the beginning of a request

   page = getPageFromUrl(url);
   if (page == null && url.EndsWith("/index.html")
      url = url.Remove("/index.html") + ".html"   // will change Contact/index.html to Contact.html

this has to be done manually, or MAYBE by overriding/implementing the UrlProvider but how that is going to work is still uncertain.

Instead, the SiteMapProvider api in Contrib which encapsulates the C1 url stuff, can easily be extended with this though. You would subclass the CompositeC1SiteMapNode and override its Url property. In here you can basically say

protected override string Url
      var oldUrl = base.Url; // this is the c1 generated url, ie /Contact.html
      if (HasChildNodes)
           var newUrl = oldUrl.Substring(oldUrl.LastIndexOf("."), 5) + "/index.html";
           return newUrl; // this will now be ie. Contact/index.html;

      return oldUrl;

   set { base.value = value; }
 now, the clever thing here, is when the request is coming in, and the SiteMapProvider makes a lookup to see if any page matches ie. /Contact/index.html it will correctly be resolved to the Contact page, since the provder has been notified of its url-change.

Jul 1, 2011 at 6:02 PM

>> Is there any idea yet of a timescale for the new release?

We don't have a planned release date yet, it will not likely be in July, since most of us have vacations this month.

Next week we will publish upgrade steps to version 2.1.3 BETA 2, which, even though not a "recommended" release/build, should be stable enough for development.