Ejemplo n.º 1
0
        /// <summary>
        /// Returns the item content item defautl Url usign the location service
        /// </summary>
        /// <param name="helper">The Html helper</param>
        /// <param name="itemType">Type of the item.</param>
        /// <param name="itemProvider">The item provider.</param>
        /// <param name="itemId">The item id.</param>
        /// /// <param name="alternativeUrl">Alternative Url of the dataItem. It will be used if the default Url is not resolved</param>
        /// <returns>The default Url of the item</returns>
        public static string GetItemDefaultUrl(this HtmlHelper helper, Type itemType, string itemProvider, Guid itemId, string alternativeUrl = null)
        {
            //first we need to get an instance of the location service
            var contentService = SystemManager.GetContentLocationService();

            // use the location service to get the item location
            var defaultLocation = contentService.GetItemDefaultLocation(itemType, itemProvider, itemId);

            return(UrlHtmlHelperExtensions.GetItemDefaultUrl(helper, defaultLocation, alternativeUrl));
        }
Ejemplo n.º 2
0
        /// <summary>
        ///  Returns the item content item defautl Url usign given content location
        /// </summary>
        /// <param name="helper">The Html helper</param>
        /// <param name="location">The location of the item</param>
        /// <param name="alternativeUrl">Alternative Url of the dataItem. It will be used if the location is null</param>
        /// <returns>The default Url of the item</returns>
        private static string GetItemDefaultUrl(this HtmlHelper helper, IContentItemLocation location, string alternativeUrl = null)
        {
            var result = string.Empty;

            if (location != null)
            {
                result = location.ItemAbsoluteUrl;
            }
            else if (!string.IsNullOrEmpty(alternativeUrl))
            {
                result = UrlHtmlHelperExtensions.GetRelativeUrl(helper, alternativeUrl);
            }

            return(result);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Returns the item content item defautl Url usign the location service
 /// </summary>
 /// <param name="helper">The Html helper</param>
 /// <param name="itemType">Type of the item.</param>
 /// <param name="viewModel">The base view model</param>
 /// /// <param name="alternativeUrl">Alternative Url of the dataItem. It will be used if the default Url is not resolved</param>
 /// <returns>The default Url of the item</returns>
 public static string GetItemDefaultUrl(this HtmlHelper helper, Type itemType, ViewModelBase viewModel, string alternativeUrl = null)
 {
     return(UrlHtmlHelperExtensions.GetItemDefaultUrl(helper, itemType, viewModel.ProviderName, viewModel.Id, alternativeUrl));
 }