1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Event Module: URL Rewriting

Event Module: URL Rewriting

10 posts, 0 answered
  1. Joe
    Joe avatar
    64 posts
    Registered:
    05 Jul 2012
    22 Apr 2008
    Link to this post
    I am having an issue with URL rewriting and the events module.

    I want my URLs to look like

    http://www.sevdnug.org/events/yyyy-mm-dd/event_title.aspx

    where yyyy-mm-dd is the Event Start Date and the event_title corresponds to the title of the event.  I have tried the following but both failed.

    <add name="Libraries" urlRewriteFormat="~/{Events.Event_Start}/[Title].aspx" urlDateTimeFormat="yyyy-MM-dd" urlWhitespaceChar="_" visible="False" defaultMetaField="Title" applicationName="/Events" ... /> 

    <add name="Events" urlRewriteFormat="~/{Event_Start}/[Title].aspx" urlDateTimeFormat="yyyy-MM-dd" urlWhitespaceChar="_" visible="False" defaultMetaField="Title" applicationName="/Events" ... /> 

  2. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    22 Apr 2008
    Link to this post
    i just figured this one out, here's what I did:
    in the web.config under <cmsEngine><providers> change the Events entry to this:

     

            <add name="Events" urlRewriteFormat="[Event_Start]/[Title].aspx" visible="True" urlWhitespaceChar="_" urlDateTimeFormat="yyyy-MM-dd" defaultMetaField="Title" securityProviderName="" allowVersioning="True" applicationName="/Events" versioningProviderName="" commentsModeration="true" connectionStringName="GenericContentConnection" type="Telerik.Events.Data.DefaultEventsProvider, Telerik.Events.Data" /> 
     

    This tells the cms how to save the rewritten url for new entries added after this change. However, if you have EXISTING entries, you have to go into the events mode and open them, then just save them. It will give it the rewritten url and that should do it!

    I hope! let me know if it works out for you!
  3. Joe
    Joe avatar
    64 posts
    Registered:
    05 Jul 2012
    22 Apr 2008
    Link to this post
    Thanks, it worked. I could have sworn that I tried that but whatever.

    As an FYI, I did not have to edit and resave the event entries because when I imported them, I set the URL to be what I wanted.
  4. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    24 Apr 2008
    Link to this post
    Hi,

    Joseph,
    We are glad that the issue is solved.

    Josh,
    Thank you for taking part in this discussion, as a sign of gratitude for the helpful answer you provided, we have updated your Telerik account.

    Best wishes,
    Georgi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    20 Oct 2008
    Link to this post
    after a few months of using the default date format i too want to use the yyyy-mm-dd format. I've updated the urldatetimeformat string but of course I need to change the urls stored for each item. is there a way to programatically do this so I don't have to go in and save each item so that it saves the new date?

    I tried playing with the eventsmanager myself to do this but I can't seem to find a way to just "save" it so it updates the url to the correct format. any help is appreciated!

    thanks
  6. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    21 Oct 2008
    Link to this post
    bump! I could really use a solution asap, thanks!
  7. Joe
    Joe avatar
    64 posts
    Registered:
    05 Jul 2012
    21 Oct 2008
    Link to this post
    Unbump.  Here is something that might help.

    Place this code into a control somewhere to call once. I have not tried it for a while to update the URL  but I believe this is what I needed to do.

    string providerName = "Events"// Or whatever your provider name is 
    // Creates the events manage 
    EventsManager eventsManager = new Telerik.Events.EventsManager(providerName); 
    // Gets all of the events 
    IList events = eventsManager.GetEvents(); 
    //Loop through each Event 
    foreach (IEvent eventItem in events) 
            // Set the title = ttiel so something has changed 
            eventItem.SetMetaData("Title", eventItem.GetMetaData("Title"); 
            // Resave, this should update the url. 
            eventsManager.Content.SaveContent(eventItem) 



    Joseph Guadagno
    Southeast Valley .NET User Group
  8. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    21 Oct 2008
    Link to this post
    ah so basically just "touch" the item? I thought i had done that but looking at my code I overlooked making a change to the item (even though it's not actually changing the data) before saving it. works like a charm, thanks!
  9. Armen
    Armen avatar
    11 posts
    Registered:
    07 Feb 2008
    17 Dec 2008
    Link to this post
    Hi,

    I have a request to rewrite Urls for news section to urlDateTimeFormat="yyyy/MM/dd". 

    I have set the it in web config and resaved all news items but seems it is not showing correctly.

    <add name="News" allowWorkflow="true" urlRewriteFormat="[Publication_Date]/[Title].aspx" urlDateTimeFormat="yy/MM/dd" urlWhitespaceChar="_" visible="False" defaultMetaField="Title" securityProviderName="" allowVersioning="True" applicationName="/News" versioningProviderName="" commentsModeration="true" connectionStringName="GenericContentConnection" type="Telerik.News.Data.DefaultNewsProvider, Telerik.News.Data"/>

    Can you please let me know how to solve this issue?

    Thanks 
    Armen 
  10. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    17 Dec 2008
    Link to this post
    Hello Armen,

    You cannot have "/" - slash character in the urlRewriteFormat. The slash will be replaced with underscore (_). The reason for this is having a slash will change the current path.
    I changed the urlRewrite format in these sections:
    <providers> 
    ... 
    <add name="News" urlRewriteFormat="[Publication_Date]/[Title].aspx"
     
    urlDateTimeFormat="yyyy/mm/dd"........ 
    </providers> 
    ... 
    <add providerName="News" 
     publicationDateField="Publication_Date"  
     expirationDateField="Expiration_Date"  
     thumbnailUrlField="Thumbnail"  
     urlRewriteFormat="[Publication_Date]/[Title].aspx"  
     urlDateTimeFormat="yyyy/MM/dd"  
     urlWhitespaceChar="_" /> 
     

    .. as a result, my News Urls look like this:
    http://localhost/3fivesp1/page/2008_00_04/news_item.aspx

    This is the behavior for all new news items. After editing and saving the rest, the url is changed for them also.
    Let me know if you have any further questions.

    Sincerely yours,
    Georgi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Register for webinar
10 posts, 0 answered