Skip to content

Commit

Permalink
Item PathParts
Browse files Browse the repository at this point in the history
  • Loading branch information
robmaas committed Jul 24, 2024
1 parent 0615b66 commit 80b06f4
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions Source/Glass.Mapper.Sc/SitecoreVersionAbstractions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Sitecore.Data.Items;
using Sitecore.Links;
using Sitecore.Resources.Media;
using Castle.Core.Internal;

namespace Glass.Mapper.Sc
{
Expand All @@ -23,7 +24,6 @@ public class SitecoreVersionAbstractions
internal static LazyResetable<BaseMediaManager> MediaManager = ServiceLocator.GetRequiredResetableService<BaseMediaManager>();
internal static LazyResetable<BaseLinkManager> LinkManager = ServiceLocator.GetRequiredResetableService<BaseLinkManager>();

internal static string renderingParamKey = "renderingParameters";
public static string GetMediaUrl(MediaItem media, MediaUrlOptions mediaUrlOptions)
{
return MediaManager.Value.GetMediaUrl(media, mediaUrlOptions);
Expand All @@ -36,12 +36,9 @@ public static string GetMediaUrl(MediaItem media)
public static string GetItemUrl(Item item, UrlOptions urlOptions)
{
#if SC104
//Added check for when rendering paramater request comes as Sitecore.Links.UrlBuilders.Helpers.ItemPathBuilder.GetRelativePath
//implementation has been changed in Sitecore 10.4
//below changes will return only url when requested for a item
if (item != null && item.Name != null && item.Name == renderingParamKey)
if (item?.Paths == null || item.Paths.GetPathParts(urlOptions?.UseDisplayName == true ? ItemPathType.DisplayName : ItemPathType.Name).IsNullOrEmpty())
{
return "/renderingparameters";
return string.Empty;
}
#endif
return LinkManager.Value.GetItemUrl(item, urlOptions);
Expand Down

0 comments on commit 80b06f4

Please sign in to comment.