Skip to content

Commit 3a2d24d

Browse files
author
michaljakubis
committed
Bump to v5.0.2
1 parent 4251541 commit 3a2d24d

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<Authors>$(Company)</Authors>
66
<Copyright>Copyright © $(Company) $([System.DateTime]::Now.Year)</Copyright>
77
<Trademark>$(Company)™</Trademark>
8-
<VersionPrefix>5.0.1</VersionPrefix>
8+
<VersionPrefix>5.0.2</VersionPrefix>
99
<VersionSuffix></VersionSuffix>
1010
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1111

src/Kentico.Xperience.TagManager/Rendering/CodeSnippetTagHelperComponent.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using CMS.ContactManagement;
22
using CMS.DataEngine;
3+
using CMS.Websites.Routing;
34

45
using Kentico.Content.Web.Mvc;
56
using Kentico.PageBuilder.Web.Mvc;
@@ -26,19 +27,22 @@ internal class CodeSnippetTagHelperComponent : TagHelperComponent
2627
private readonly IFileVersionProvider fileVersionProvider;
2728
private readonly IHttpContextAccessor httpContextAccessor;
2829
private readonly IWebPageDataContextRetriever webPageDataContextRetriever;
30+
private readonly IWebsiteChannelContext websiteChannelContext;
2931

3032
public CodeSnippetTagHelperComponent(
3133
IChannelCodeSnippetsService codeSnippetsContext,
3234
IUrlHelperFactory urlHelperFactory,
3335
IFileVersionProvider fileVersionProvider,
3436
IHttpContextAccessor httpContextAccessor,
35-
IWebPageDataContextRetriever webPageDataContextRetriever)
37+
IWebPageDataContextRetriever webPageDataContextRetriever,
38+
IWebsiteChannelContext websiteChannelContext)
3639
{
3740
this.codeSnippetsContext = codeSnippetsContext;
3841
this.urlHelperFactory = urlHelperFactory;
3942
this.httpContextAccessor = httpContextAccessor;
4043
this.fileVersionProvider = fileVersionProvider;
4144
this.webPageDataContextRetriever = webPageDataContextRetriever;
45+
this.websiteChannelContext = websiteChannelContext;
4246
}
4347

4448
/// <summary>
@@ -52,16 +56,20 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu
5256
{
5357
var contact = ContactManagementContext.CurrentContact;
5458

55-
if (!webPageDataContextRetriever.TryRetrieve(out var webPageDataContext))
59+
if (websiteChannelContext.WebsiteChannelID <= 0)
5660
{
5761
return;
5862
}
5963

60-
var contentTypeName = webPageDataContext.WebPage.ContentTypeName;
61-
var dataClass = DataClassInfoProvider.GetDataClassInfo(contentTypeName);
62-
6364
// Get the current page's content type ID
64-
int? contentTypeId = dataClass?.ClassID;
65+
int? contentTypeId = null;
66+
if (webPageDataContextRetriever.TryRetrieve(out var webPageDataContext))
67+
{
68+
var contentTypeName = webPageDataContext.WebPage.ContentTypeName;
69+
var dataClass = DataClassInfoProvider.GetDataClassInfo(contentTypeName);
70+
71+
contentTypeId = dataClass?.ClassID;
72+
}
6573

6674
var codeSnippets = await codeSnippetsContext.GetConsentedCodeSnippets(contact, contentTypeId);
6775

0 commit comments

Comments
 (0)