Create Custom URL Format for Content Items Created using Mod

Posted by Community Admin on 04-Aug-2018 17:51

Create Custom URL Format for Content Items Created using Module Builder

All Replies

Posted by Community Admin on 08-Jan-2013 00:00

Hi,

How do you customize the URL for a custom module that is built using Module Builder?  

For example, I've created a Module called Cars and a content item with the title of Car Number One.  How would I output the URL as mysite/.../car-number-one instead of the default http://mysite/car-number-one?


I found a blog post that explains how to customize the URL formats for the News and Blogs module, http://www.sitefinity.com/blogs/slavoingilizov/posts/slavo-ingilizovs-blog/2011/10/19/custom_url_formats_for_sitefinity_content_modules,  but it doesn't seem to work with modules created with Module Builder.  

I am using Sitefinity 5.2.3800.0 standard.

Thanks

Posted by Community Admin on 09-Jan-2013 00:00

Hello Bryan,

I think there are two possible ways to achieve that. First one is by the blog post you have mentioned. I created a new file "CustomProvider" that will extend the dynamic module provider. Here is my CustomProvider.cs

using Telerik.Sitefinity.DynamicModules.Data;
using Telerik.Sitefinity.GenericContent.Model;
 
 
namespace SitefinityWebApp
    public class CustomProvider : OpenAccessDynamicModuleProvider
    
        public override string GetUrlFormat(ILocatable item)
        
            string urlFormat = "/[UrlName]";
            if (item.GetType().FullName == "Telerik.Sitefinity.DynamicTypes.Model.Cars.Car")
            
                urlFormat = "/Cars/[UrlName]";
            
 
            return urlFormat;
        
    


It is required to check the content type of your item because the provider is common for all of the dynamic types. Build your solution, open Administration -> Settings -> Advanced -> DynamicModules -> Providers and create a new one. Set Title and Name to any value. For ProviderType enter your type, in my case SitefinityWebApp.CustomProvider, save and restart your application. You can see my settings here:



Then create some items in that provider and in the dynamic widgets change the provider property as shown in the blog post (you should have provider selector when the widget is opened for edit). Now by opening details view of the items urls should be with the correct format.

Another solution for that problem might be to create a page named "Cars" and make the dynamic content widget redirect to that page. I have recorded a short video demonstrating that -> http://screencast.com/t/2Q4xTVOvZP

I would like to mention that the trick with providers will work for Sitefinity versions after 5.2 while for 5.1 and before only the workaround with pages will work.

Kind regards,
Stoimen Stoimenov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed