XperienceCommunity.PageBuilderTagHelpers 1.1.0

dotnet add package XperienceCommunity.PageBuilderTagHelpers --version 1.1.0                
NuGet\Install-Package XperienceCommunity.PageBuilderTagHelpers -Version 1.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="XperienceCommunity.PageBuilderTagHelpers" Version="1.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add XperienceCommunity.PageBuilderTagHelpers --version 1.1.0                
#r "nuget: XperienceCommunity.PageBuilderTagHelpers, 1.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install XperienceCommunity.PageBuilderTagHelpers as a Cake Addin
#addin nuget:?package=XperienceCommunity.PageBuilderTagHelpers&version=1.1.0

// Install XperienceCommunity.PageBuilderTagHelpers as a Cake Tool
#tool nuget:?package=XperienceCommunity.PageBuilderTagHelpers&version=1.1.0                

Xperience Page Builder Utilities

Dependencies

These libraries are compatible with ASP.NET Core 3.1 → ASP.NET Core 5 and are designed to be used with the Xperience 13.0 Content Delivery (MVC) application running on ASP.NET Core.

Page Builder Utilities

This library provides an abstraction over the Kentico Xperience Page Builder rendering mode so that developers can conditionally execute code based on the mode of a given HTTP request to their ASP.NET Core application.

How to Use?

  1. First, install the NuGet package in your ASP.NET Core project:

    dotnet add package XperienceCommunity.PageBuilderUtilities
    
  2. Add the required types to the DI container in your Startup.cs file

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddPageBuilderContext();
    }
    
  3. You can now use the IPageBuilderContext from XperienceCommunity.PageBuilderUtilities as a constructor dependency anywhere in your application to more easily determine the state of the current request:

    public class ProductsController
    {
        private readonly IPageBuilderContext context;
    
        public ProductsController(IPageBuilderContext context) =>
            this.context = context;
    
        public ActionResult Index()
        {
            if (context.IsEditMode)
            {
                // ...
            }
    
            if (context.IsLivePreviewMode)
            {
                // ...
            }
    
            if (context.IsLiveMode)
            {
                // ...
            }
    
            if (context.IsPreviewMode)
            {
                // ...
            }
        }
    }
    
  4. By not using IHttpContextAccessor and all the Kentico Xperience extension methods, your code is both easier to unit test and read.

  5. You can inject this type into your Razor views, but the better option is to use ... 👇

Page Builder Tag Helpers

This library provides an ASP.NET Core Tag Helper for Kentico Xperience 13.0 to help toggle HTML in Razor views based on the Page Builder 'mode' of the request to the ASP.NET Core application.

How to Use?

  1. First, install the NuGet package in your ASP.NET Core project

    dotnet add package XperienceCommunity.PageBuilderTagHelpers
    
  2. Add the required types to the DI container in your Startup.cs file

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddPageBuilderContext();
    }
    
    • Note: This extension method comes from the XperienceCommunity.PageBuilderUtilities package, above, which is a dependency of XperienceCommunity.PageBuilderTagHelpers
  3. Include the tag helper assembly name in the ~/Views/_ViewImports.cshtml

    @addTagHelper *, XperienceCommunity.PageBuilderTagHelpers
    
  4. Use the tag helper in your Razor views

    <page-builder-mode exclude="Live">
    
      <h1>Hello!</h1>
    </page-builder-mode>
    
    <page-builder-mode include="LivePreview, Edit">
    
      <h1>Hello!</h1>
    </page-builder-mode>
    
    <page-data-context> 
    
      <widget-zone />
    </page-data-context>
    
    <page-data-context initialized="false">
    
      <div>widget placeholder!</div>
    </page-data-context>
    

References

Real World Examples

ASP.NET Core

Kentico Xperience

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on XperienceCommunity.PageBuilderTagHelpers:

Package Downloads
XperienceCommunity.Baseline.Core.Library.KX13

The Baseline a set of Core Systems, Tools, and Structure to ensure a superior Kentico Website that's easy to migrate, for Kentico Xperience 13 and eventually Xperience by Kentico

XperienceCommunity.CQRS.Web

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 56,183 12/30/2021
1.1.0-beta.1 141 12/30/2021
1.0.0 938 10/20/2021