Skip to content

Commit 0edf643

Browse files
CopilotmichalJakubismichaljakubis
authored
Fix: Filter tags from Form Builder and admin contexts when DisplayMode is None (#87)
* Initial plan * Fix tags showing in admin contexts like Form Builder Co-authored-by: michalJakubis <64188398+michalJakubis@users.noreply.github.com> * Improve null safety in IsAdminContext method Co-authored-by: michalJakubis <64188398+michalJakubis@users.noreply.github.com> * Render tag in web page context only * Fix formatting --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: michalJakubis <64188398+michalJakubis@users.noreply.github.com> Co-authored-by: michaljakubis <michalj@kentico.com>
1 parent 2d2552b commit 0edf643

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,17 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu
5252
{
5353
var contact = ContactManagementContext.CurrentContact;
5454

55-
// Get the current page's content type ID
56-
int? contentTypeId = null;
57-
if (webPageDataContextRetriever.TryRetrieve(out var webPageDataContext))
55+
if (!webPageDataContextRetriever.TryRetrieve(out var webPageDataContext))
5856
{
59-
var contentTypeName = webPageDataContext.WebPage.ContentTypeName;
60-
var dataClass = DataClassInfoProvider.GetDataClassInfo(contentTypeName);
61-
62-
contentTypeId = dataClass?.ClassID;
57+
return;
6358
}
6459

60+
var contentTypeName = webPageDataContext.WebPage.ContentTypeName;
61+
var dataClass = DataClassInfoProvider.GetDataClassInfo(contentTypeName);
62+
63+
// Get the current page's content type ID
64+
int? contentTypeId = dataClass?.ClassID;
65+
6566
var codeSnippets = await codeSnippetsContext.GetConsentedCodeSnippets(contact, contentTypeId);
6667

6768
if (string.Equals(context.TagName, HeadTag, StringComparison.OrdinalIgnoreCase))
@@ -155,6 +156,7 @@ private void ProcessBody(
155156
output.PostContent.AppendHtml(GetScriptSrcTag());
156157
}
157158

159+
158160
private IHtmlContent GetScriptSrcTag()
159161
{
160162
var urlHelper = urlHelperFactory.GetUrlHelper(ViewContext);

0 commit comments

Comments
 (0)