Blog Post Custom URLs

Posted by Community Admin on 04-Aug-2018 01:32

Blog Post Custom URLs

All Replies

Posted by Community Admin on 21-Aug-2013 00:00

I found this article (custom_url_formats_for_sitefinity_content_modules) on specifying a custom URL format for news and blog posts.  However, after following the instructions, everything appears to be working except the URLs are unchanged.  I have the custom blog provider and a blog posts widget which displays the blogs created under that provider. 
Here is the code I'm using (which is the same as from the article):

public class BlogProviderNoDateUrls : OpenAccessBlogProvider
    /// <summary>
    /// The URL format string for blog items
    /// </summary>
    public string BlogUrlFormat
    
        get;
        set;
    
 
    /// <summary>
    /// The URL format string for blog post items
    /// </summary>
    public string BlogPostUrlFormat
    
        get;
        set;
    
 
    public override string GetUrlFormat(Telerik.Sitefinity.GenericContent.Model.ILocatable item)
    
        if (item.GetType() == typeof(Blog))
        
            return this.BlogUrlFormat;
        
        else if (item.GetType() == typeof(BlogPost))
        
            return this.BlogPostUrlFormat;
        
        else
        
            return base.GetUrlFormat(item);
        
    
 
    protected override void Initialize(string providerName, System.Collections.Specialized.NameValueCollection config, Type managerType)
    
        base.Initialize(providerName, config, managerType);
        this.BlogUrlFormat = config["blogUrlFormat"];
        if (String.IsNullOrEmpty(this.BlogUrlFormat))
        
            this.BlogUrlFormat = "/[UrlName]";
        
        this.BlogPostUrlFormat = config["blogPostUrlFormat"];
        if (String.IsNullOrEmpty(this.BlogPostUrlFormat))
        
            this.BlogPostUrlFormat = "/[Parent.UrlName]/[PublicationDate, 0:yyyy'/'MM'/'dd]/[UrlName]";
        
    

When I set a breakpoint in "GetUrlFormat" or "Initialize" I can see that these breakpoints are hit and the property "BlogPostUrlFormat" has the value I set for it in the parameter (which is “/[PublicationDate, 0:yyyy'/'MM'/'dd]/[UrlName]").  The only difference is that Sitefinity didn't accept the value "/[UrlData]" for the blogUrlFormat parameter in the Sitefinity advanced configuration.  The result of trying to use that value was an error saying that value wasn't recognized.  So I used "/[UrlName]" as the value instead.

*Note that another problem is that after changing the provider name on the blog posts widget, the list of blogs in the "From selected glogs only..." option is from the default provider, not the custom provider.  But choosing "From all blogs" does result in it displaying the blogs from the custom provider, so I am not too concerned about this problem yet.

Posted by Community Admin on 23-Aug-2013 00:00

Hello Jeff,

Thank you for contacting us.

I have inspected the code sample and everything looks good. I have to try this solution on my test project and see if it is work for version 6.1. I will update you with information as soon as I have a result.

Thank you for your patience.

Regards,
Kaloyan
Telerik

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

Posted by Community Admin on 23-Aug-2013 00:00

Thanks.

Note that I am using Sitefinity 5.1.3450.0 for this web site.

Posted by Community Admin on 09-Jun-2015 00:00

Hi all,

I followed the steps. The thing is when we preview the draft or unpublished blog it throws a 404.

The Sitefinity URL query rules for preview no longer show. Is there a fix for this?

Posted by Community Admin on 09-Jun-2015 00:00

I followed the steps. The thing is when we preview the draft or unpublished blog it throws a 404.
The Sitefinity URL query rules for preview no longer show. Is there a fix for this?

This thread is closed