Additional URL's in events
Hello,
we're trying to setup additional url's for events but are receiving 404's. Seems like a very straightforward task. I've read many related posts in the Sitefinity Forums pages but have found nothing that addresses our issue.
Simply stated, we want to be able to access a page such as
testdomain.com/.../annual-meeting
via a shortened url like testdomain.com/annualmeeting.
Within the specific event fields I have selected 'allow multiple url's for this item'. I have specified the shortened url of '~/annualmeeting' in the additional url's entry. I have also selected 'all additional url's redirect to the default one.'
I have tried different permutations of these fields as well - like using '~/annualmeeting.aspx' instead as I read one was doing in a different thread.
Still no luck, any suggestions would be greatly appreciated.
thanks in advance
Hello Ryan,
The additional URL "replaces" the Event data, for example:
/2014/10/20/default-calendar/usa-ca-1
so in case you have detail event view on: www.mysite.com/events/2014/10/20/default-calendar/usa-ca-1,
the additional url will looks like:
www.mysite.com/events/my-event-1,
Screenshot is available here.
Regards,
Svetoslav Manchev
Telerik
Hello Svetoslav,
thanks for your reply. My apologies as I had not investigated the issue thoroughly before posting the original question. The issue appears to not be the additional url redirects themselves but a problem in the page load of a control on the page. We are trying to use
this.currentEvent = EventHelper.GetCurrentEvent(this.GetUrlParameterString(true));
to return the actual event. However, the shortened url is not recognized in this situation. Can you tell me if there is recommended way to return the event based on the alternate, shortened url? Thanks again for any information you can provide.
Best regards,
Hello again Svetoslav,
as a follow-up...
we are trying to retrieve information for a specific event using the following:
var manager = EventsManager.GetManager();
Event ev = manager.GetEvents().Where(e => e.ItemDefaultUrl == itemUrl && e.Status == ContentLifecycleStatus.Master).SingleOrDefault() as Event;.
The itemUrl is being retrieved using var ps = this.GetUrlParameterString(true); This normally works fine, however, when one of the event's additional urls is used the GetEvents() method returns null.
Can you please advise if we can retrieve the event via a more specific Linq query or if there is another method to accomplish this task. As this is being done in page load, we are assuming the redirect has not yet occurred and this is why the itemUrl is being returned as the additional url and not the original event url. Can you please address this point as well.
Best regards,
Hi Ryan,
In order to include the additional urls in your query, you need to check the UrlData which includes all the Item Urls, for example:
var manager = EventsManager.GetManager();
var itemUrl =
this
.GetUrlParameterString(
true
);
// var urls = manager.GetEvents().First().Urls; // just for example
Event evt = manager
.GetEvents()
.Where(ev => ev.Urls.Where(url=>url.Url == itemUrl).Count()>0
&& ev.Status == ContentLifecycleStatus.Master)
.SingleOrDefault();