[Progress Communities] [Progress OpenEdge ABL] Forum Post: RE: Getting DefaultLocation on Client side

Status
Not open for further replies.
J

jread

Guest
So not directly out of the box but you can add a custom field to the service use the below code to get the default location of the item. There are two public methods in the below helper class that can get a content items default location. Also included how to add a custom field to web services: Custom calculated properties - Sitefinity CMS Development using System; using System.Collections.Generic; using System.Linq; using System.Web; using Telerik.Sitefinity.ContentLocations; using Telerik.Sitefinity.Model; using Telerik.Sitefinity.Services; namespace SitefinityWebApp { public static class ContentLocationHelper { /// /// Retrives the page url of where the content item exists /// /// Content Item /// Url of page where content item is publish. This does not return the conent items default location. public static string GetDefaultPageUrl(IDataItem content) { string url = string.Empty; IContentItemLocation itemLocation = GetItemLocation(content); if (itemLocation != null) { url = PagesHelper.GetPageUrlById(itemLocation.PageId); } return url; } /// /// Gets content items default location /// /// Conent item /// Content item location object private static IContentItemLocation GetItemLocation(IDataItem content) { var locationsService = SystemManager.GetContentLocationService(); var itemLocation = locationsService.GetItemDefaultLocation(content.GetType(),content.Provider.ToString(), content.Id); return itemLocation; } /// /// Get content items full url path /// /// Content item /// Full url path to conent item public static string GetContentItemFullUrl(IDataItem content) { string url = string.Empty; IContentItemLocation itemLocation = GetItemLocation(content); if (itemLocation != null) { url = itemLocation.ItemAbsoluteUrl; } return url; } } } using System; using System.Collections; using System.Collections.Generic; using Telerik.Sitefinity; using Telerik.Sitefinity.Data; using Telerik.Sitefinity.Model; using Telerik.Sitefinity.Web.Services.Extensibility; namespace SitefinityWebApp { internal class ProviderNameProperty : CalculatedProperty { public override Type ReturnType { get { return typeof(string); } } public override IDictionary GetValues(IEnumerable items, IManager manager) { var ret = new Dictionary (); foreach (IDataItem item in items) { ret.Add(item, SitefinityWebApp.GetDefaultPageUrl(item)); } return ret; } } }

Continue reading...
 
Status
Not open for further replies.
Top