Content Sharing Across Multiple Sites
I have created a custom widget that will be used in sitefinity 7.0. It will be used in two sites. I need to know how do I let the user select which content provider to use for the widget? Also can I create a drop down list in the designer that will allow the user to select either the default provider of the Open Access Provider. Two sites one content management system.
Hello,
Would it be possible to share some more information regarding the type of content that this widget will display? Also, what will the widget do? Will the user just select the provider in the designer and then the widget should display the content?
Regards,
Atanas Valchev
Telerik
The widget will display events in jquery fullcalendar. It will display the start, end time of event. Title, description, and url of events. Yes, the user will select the provider from a drop down list in the designer and the calendar will display the events or content.
Here is what I have so far.
namespace SitefinityWebApp.Custom.CalendarEvents.Model
public class CalendarEvent
public Guid id get; set;
public string title get; set;
public DateTime? start get; set;
public DateTime? end get; set;
public string url get; set;
public string summary get; set;
public bool sac get; set; //sac = ShowAndCancel
public static IEnumerable<CalendarEvent> LoadAllEvents( DateTime start, DateTime end, string tagValue, string categoryValue, string categoryName, string tagName)
var selectedCategories = StringToArray(categoryValue);
var selectedTags = StringToArray(tagValue);
//var Category = StringToArray(categoryName);
//var Tags = StringToArray(tagName);
var providerNames = SystemManager.CurrentContext.CurrentSite.SiteDataSourceLinks.Where(o => o.DataSourceName == typeof(EventsManager).FullName).Select(o => 0.ProviderName);
var taxonomyManager = TaxonomyManager.GetManager();
var taxon = taxonomyManager.GetTaxa<FlatTaxon>().Where(t => t.Name == "calendar-event").Single();
var manager = EventsManager.GetManager();
var ev = manager.GetEvents()
.Where(t => t.GetValue<TrackedList<Guid>>("Category").Any(j => selectedCategories.Contains(j))
&& t.GetValue<TrackedList<Guid>>("Tags").Any(j => selectedTags.Contains(j))
&& t.GetValue<TrackedList<Guid>>("Tags").Any(j => j == taxon.Id)
&& t.GetValue<TrackedList<Guid>>("Tags").Count > 0
&& t.Visible
&& t.Status == ContentLifecycleStatus.Live
&& t.EventStart >= start
&& t.EventStart <= end);
var events = manager.GetEventsOccurrences(ev, start, end)
.ToList().Select(e => new CalendarEvent
id = e.Event.Id,
start = e.StartDate.ToLocalTime(),
end = ((DateTime)e.EndDate).ToLocalTime(),
title = e.Title,
url = e.Event.ItemDefaultUrl + "?StartDate=" + System.Web.HttpUtility.UrlEncode(string.Format("0:ddd, MMM d, yyyy, h:mm tt", e.StartDate.ToLocalTime())) + "&EndDate=" + System.Web.HttpUtility.UrlEncode(string.Format("0:ddd, MMM d, yyyy, h:mm tt", ((DateTime)e.EndDate).ToLocalTime())),
summary = String.IsNullOrEmpty(e.Event.Summary) ? String.IsNullOrEmpty(e.Event.Content) ? "This event does not have a description." : RemoveHTML(e.Event.Content.ToString()).Length > 200 ? RemoveHTML(e.Event.Content.ToString()).Substring(0, 200) : RemoveHTML(e.Event.Content.ToString()) : e.Event.Summary.ToString(),
sac = e.Event.GetValue<bool>("CancelEvent")
).Distinct();
return events;
public static string RemoveHTML(string strHTML)
return Regex.Replace(strHTML, "<(.|\n)*?>", "") + "...";
private static DateTime ConvertFromUnixTimestamp(double timestamp)
var origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
return origin.AddSeconds(timestamp);
/// The tag value as a comma delimited string.
private static Guid[] StringToArray(string data)
var list = new List<Guid>();
if (data != null)
var guids = data.Split(',');
foreach (var guid in guids)
Guid newGuid;
if (Guid.TryParse(guid, out newGuid))
list.Add(newGuid);
return list.ToArray();