XperienceCommunity.LinkablePages
3.0.0
dotnet add package XperienceCommunity.LinkablePages --version 3.0.0
NuGet\Install-Package XperienceCommunity.LinkablePages -Version 3.0.0
<PackageReference Include="XperienceCommunity.LinkablePages" Version="3.0.0" />
<PackageVersion Include="XperienceCommunity.LinkablePages" Version="3.0.0" />
<PackageReference Include="XperienceCommunity.LinkablePages" />
paket add XperienceCommunity.LinkablePages --version 3.0.0
#r "nuget: XperienceCommunity.LinkablePages, 3.0.0"
#:package XperienceCommunity.LinkablePages@3.0.0
#addin nuget:?package=XperienceCommunity.LinkablePages&version=3.0.0
#tool nuget:?package=XperienceCommunity.LinkablePages&version=3.0.0
Xperience Page Links
Packages
LinkablePages
Kentico Xperience 13.0 custom module to protect pages referenced in code from deletion and shared abstractions for linkable pages.
This package is compatible with .NET Standard 2.0 libraries integrated with Kentico Xperience 13.0.
PageLinkTagHelpers
Kentico Xperience 13.0 ASP.NET Core Tag Helper that generates links to predefined pages using their NodeGUID values, and extension methods for registering dependencies in ASP.NET Core.
This package is compatible with ASP.NET Core 3.1+ applications or libraries integrated with Kentico Xperience 13.0.
How to Use?
Install the
XperienceCommunity.LinkablePagesNuGet package in a class library shared by your ASP.NET Core and CMS applications:dotnet add package XperienceCommunity.LinkablePagesIn the shared class library, create a class implementing the
ILinkablePagewhere you define pages that are available to the tag helper:Populate the
Guidvalues with theNodeGUIDof each page in the content tree that you need to link to in your application.using XperienceCommunity.LinkablePages;public namespace Sandbox.Shared { public class LinkablePage : ILinkablePage { public static LinkablePage Home { get; } = new LinkablePage(new Guid("...")); public static LinkablePage Store { get; } = new LinkablePage(new Guid("...")); public static LinkablePage ContactUs { get; } = new LinkablePage(new Guid("...")); public static LinkablePage TermsOfUse { get; } = new LinkablePage(new Guid("...")); public Guid NodeGUID { get; } protected LinkablePage(Guid nodeGUID) => NodeGUID = nodeGUID; public static IReadOnlyList<LinkablePage> All { get; } = new List<LinkablePage> { Home, Store, ContactUs, TermsOfUse }; } }In the shared class library, create an implementation of the
ILinkablePageInventoryinterface, which will be used to determine which Pages in the application should be protected:using XperienceCommunity.LinkablePages;public class LinkablePageInventory : ILinkablePageInventory { public bool IsLinkablePage(TreeNode page) { return LinkablePage.All.Any(p => p.NodeGUID == page.NodeGUID); } }Install the
XperienceCommunity.PageLinkTagHelpersNuGet package in your ASP.NET Core project:dotnet add package XperienceCommunity.PageLinkTagHelpersAdd the
@addTagHelperdirective to your_ViewImports.cshtmlfile:(optional) Add your
LinkablePageclass's namespace to your_ViewImports.cshtmlfile (e.g.,Sandbox.Shared).// Add this using to make LinkablePages easy to access in Views @using Sandbox.Shared @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @addTagHelper *, Kentico.Content.Web.Mvc @addTagHelper *, Kentico.Web.Mvc @addTagHelper *, DancingGoatCore // Add this directive to use the Tag Helper @addTagHelper *, XperienceCommunity.PageLinkTagHelpersRegister the library with ASP.NET Core DI:
using XperienceCommunity.LinkablePages;public void ConfigureServices(IServiceCollection services) { // Use standard registration services .AddXperienceCommunityPageLinks() .AddXperienceCommunityPageLinksProtection<LinkablePageInventory>(); // or use a custom implementation of ILinkablePageLinkRetriever services .AddXperienceCommunityPageLinks<MyCustomLinkablePageLinkRetriever>() .AddXperienceCommunityPageLinksProtection<LinkablePageInventory>(); }Add the data protection custom module registration to your ASP.NET Core application (in
Startup.csor wherever you register your dependencies):using XperienceCommunity.LinkablePages; [assembly: RegisterModule(typeof(LinkablePageProtectionModule))]Use the
xp-page-linktag helper in an<a>element in a Razor View:<a href="" xp-page-link="LinkablePage.Home"> <img src="/getmedia/10d5e094-d9aa-4edf-940d-098ca69b5f77/logo.png" alt="..." /> </a>Create a custom module class in your CMS application to register the
LinkablePageProtectionModuleand theILinkablePageInventoryimplementation:using XperienceCommunity.LinkablePages;// Registers this custom module class [assembly: RegisterModule(typeof(DependencyRegistrationModule))] // Registers the library's custom module class [assembly: RegisterModule(typeof(LinkablePageProtectionModule))] namespace CMSApp { public class DependencyRegistrationModule : Module { public DependencyRegistrationModule() : base(nameof(DependencyRegistrationModule)) { } protected override void OnPreInit() { base.OnPreInit(); // Registers the ILinkablePageInventory implementation used by the LinkablePageProtectionModule Service.Use<ILinkablePageInventory, LinkablePageInventory>(); } } }Use Kentico Xperience's Content Staging to keep your
LinkablePageNodeGUIDvalues valid between different environments.
Usage
Simple
Razor (assuming the ContactUs Page has a DocumentName of "Contact Us"):
<a href="" xp-page-link="LinkablePage.ContactUs"></a>
Generated HTML will set the child content, href and title attributes:
<a href="/contact-us" title="Contact Us">Contact Us</a>
Custom Content
Razor (assuming the ContactUs Page has a DocumentName of "Contact Us"):
<a href="" title="Please contact us" xp-page-link="LinkablePage.ContactUs">
<img src="..." />
</a>
Generated HTML will keep the child content and only set the href and title attributes:
<a href="/contact-us" title="Please contact us">
<img src="..." />
</a>
Empty Title Attribute with Child Content
Razor:
<a href="" title="" xp-page-link="LinkablePage.ContactUs">
No title necessary!
</a>
Generated HTML will not populate the title attribute, assuming the child content provides some text:
<a href="/contact-us" title=""> No title necessary! </a>
Empty Title Attribute with No Child Content
Razor (assuming the ContactUs Page has a DocumentName of "Contact Us"):
<a href="" title="" xp-page-link="LinkablePage.ContactUs"> </a>
Generated HTML will populate the title for accessibility:
<a href="/contact-us" title="Contact Us"> Contact Us </a>
Query String Parameters
Razor:
<a
href=""
xp-page-link="LinkablePage.ContactUs"
title="Please contact us"
xp-page-link-query-params="@(new() { { "parameter": "value" } })">
Contact us for help!
</a>
Generated HTML will include query string parameters in the href, and set the title attribute/child content as appropriate:
<a href="/contact-us?parameter=value" title="Please contact us">
Contact us for help!
</a>
Contributions
If you discover a problem, please open an issue.
If you would like contribute to the code or documentation, please open a pull request.
References
.NET
Kentico Xperience
| Product | Versions 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Kentico.Xperience.Libraries (>= 13.0.0 && < 13.1.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on XperienceCommunity.LinkablePages:
| Package | Downloads |
|---|---|
|
XperienceCommunity.PageLinkTagHelpers
Provides ASP.NET Core Tag Helpers for Kentico Xperience 13.0 applications to help developers easily generate links to pages in the content tree. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0 | 3,721 | 10/10/2022 |
| 3.0.0-prerelease-8-2 | 360 | 10/10/2022 |
| 2.0.0 | 911 | 8/20/2022 |
| 2.0.0-prerelease-7-1 | 343 | 8/20/2022 |