I think you could use the 'umbracoUrlAlias' property to provide an additional url for each page. Take a look at this documentation page for more information. You could also create an event to set the property when the product page is saved.
True but you could create a SurfaceController for your Document Type to check which URL a visitor is using. If using the default URL, you could redirect the visitor to the umbracoUrlAlias version. Its a bit hacky but it would allow you to have the URL structure you'd require.
another way of achieving this is using the power of UrlProviders (http://www.zpqrtbnk.net/TheUmbraco6RequestPipeline.pdf).
If you implement the interface IUrlProvider in this way:
public class YourUrlProvider : IUrlProvider { public IEnumerable<string> GetOtherUrls(Umbraco.Web.UmbracoContext umbracoContext, int id, Uri current) { return Enumerable.Empty<string>(); }
/// <summary> /// Implements a better version of getURL; /// </summary> /// <param name="umbracoContext"></param> /// <param name="id"></param> /// <param name="current"></param> /// <param name="mode"></param> /// <returns></returns> public string GetUrl(Umbraco.Web.UmbracoContext umbracoContext, int id, Uri current, UrlProviderMode mode) { var node = umbracoContext.ContentCache.GetById(id); if (node != null && node.Parent != null) { if (node.DocumentTypeAlias == "YourSingleProductDocType") return umbraco.cms.helpers.url.FormatUrl(node.Name) + "/"; }
return null; } }
And you add the URLProvider like this
public class OnStartUp : IApplicationEventHandler { public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) {
}
public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) {
}
public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) { UrlProviderResolver.Current.InsertType<YourUrlProvider>(); } }
In that way Umbraco will do all the hard stuff for you.
Well I was hoping for configuration type solution. I'm not a .Net developer, so VS, compiling and so on is really not something I want to get into. I feel that it should be possible to have full control over the url, without having to resort to .Net development.
But I guess I'll solve it by having a folder with all the pages, and then build my menu with shortcut doctypes, pointing to those pages.
Aah, I see. In that case creating a "Textstring" - property with the alias "umbracoUrlAlias" is the best way. In newer versions of Umbraco the url will completely be replaced instead of creating two url's (the documentation is a bit old).
Flat URL structure
This seems like a simple question, but I've looked through the other posts and haven't really found a defnite answer.
Usually the structure and URLs of a site is like this:
- Content
- Home (url= /)
- About Us (url= /about-us)
- Products (url= /products)
- SingleProduct (url= /products/singleproduct)
- Contact (url= /contact)
But would it possible to do this
- Content
- Home (url= /)
- About Us (url= /about-us)
- Products (url= /products)
- SingleProduct (url= /singleproduct)
- Contact (url= /contact)
The change is that all URLs is under the root node.
I think you could use the 'umbracoUrlAlias' property to provide an additional url for each page. Take a look at this documentation page for more information. You could also create an event to set the property when the product page is saved.
Thanks, Dan.
Hi Dan
But multiple URLs to the same content would result in duplicate content.
True but you could create a SurfaceController for your Document Type to check which URL a visitor is using. If using the default URL, you could redirect the visitor to the umbracoUrlAlias version. Its a bit hacky but it would allow you to have the URL structure you'd require.
Thanks, Dan.
"Unnecessary" redirects are not an option as the client is very SEO capaple and minded and would point that out immediately. :-/
You could always throw a 404 exception instead of a redirect. That should solve your duplicate content problem and not wanting unnecessary redirects.
Thanks, Dan.
Hi Ørskov,
another way of achieving this is using the power of UrlProviders (http://www.zpqrtbnk.net/TheUmbraco6RequestPipeline.pdf).
If you implement the interface IUrlProvider in this way:
And you add the URLProvider like this
In that way Umbraco will do all the hard stuff for you.
Hope it helps,
Jeffrey
Well I was hoping for configuration type solution. I'm not a .Net developer, so VS, compiling and so on is really not something I want to get into. I feel that it should be possible to have full control over the url, without having to resort to .Net development.
But I guess I'll solve it by having a folder with all the pages, and then build my menu with shortcut doctypes, pointing to those pages.
Aah, I see. In that case creating a "Textstring" - property with the alias "umbracoUrlAlias" is the best way. In newer versions of Umbraco the url will completely be replaced instead of creating two url's (the documentation is a bit old).
Good luck!
is working on a reply...