{"id":21328423,"url":"https://github.com/wiredviews/xperience-page-template-utilities","last_synced_at":"2025-07-12T07:31:58.973Z","repository":{"id":98317975,"uuid":"349766387","full_name":"wiredviews/xperience-page-template-utilities","owner":"wiredviews","description":"Utilities to help quickly create and register MVC Page Templates in Kentico Xperience","archived":false,"fork":false,"pushed_at":"2022-10-31T04:48:22.000Z","size":53,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-06T16:08:37.044Z","etag":null,"topics":["aspnetcore","kentico-xperience","xperience"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wiredviews.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-20T15:42:18.000Z","updated_at":"2022-11-16T11:22:19.000Z","dependencies_parsed_at":"2023-06-28T19:31:08.943Z","dependency_job_id":null,"html_url":"https://github.com/wiredviews/xperience-page-template-utilities","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/wiredviews/xperience-page-template-utilities","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiredviews%2Fxperience-page-template-utilities","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiredviews%2Fxperience-page-template-utilities/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiredviews%2Fxperience-page-template-utilities/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiredviews%2Fxperience-page-template-utilities/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wiredviews","download_url":"https://codeload.github.com/wiredviews/xperience-page-template-utilities/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiredviews%2Fxperience-page-template-utilities/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264958135,"owners_count":23689006,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aspnetcore","kentico-xperience","xperience"],"created_at":"2024-11-21T21:28:53.263Z","updated_at":"2025-07-12T07:31:58.742Z","avatar_url":"https://github.com/wiredviews.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Xperience Page Template Utilities\n\n[![NuGet Package](https://img.shields.io/nuget/v/XperienceCommunity.PageTemplateUtilities.svg)](https://www.nuget.org/packages/XperienceCommunity.PageTemplateUtilities)\n\nUtilities to help quickly create and register MVC Page Templates in Kentico Xperience\n\n## Dependencies\n\nThis package is compatible with ASP.NET Core 3.1 -\u003e ASP.NET Core 5 and is designed to be used with .NET Core / .NET 5 applications integrated with Kentico Xperience 13.0.\n\n## How to Use?\n\n1. First, install the NuGet package in your ASP.NET Core project\n\n   ```bash\n   dotnet add package XperienceCommunity.PageTemplateUtilities\n   ```\n\n1. Create an implementation of `PageTypePageTemplateFilter` for a given Page Type and register some Page Templates\n\n   ```csharp\n   [assembly: RegisterPageTemplate(\n       \"Sandbox.HomePage_Default\",\n       \"Home Page (Default)\",\n       typeof(HomePageTemplateProperties),\n       \"~/Features/Home/Sandbox.HomePage_Default.cshtml\")]\n\n   public class HomePageTemplateFilter : PageTypePageTemplateFilter\n   {\n        public override string PageTypeClassName =\u003e \"Sandbox.HomePage\";\n   }\n   ```\n\n1. Register all `IPageTemplateFilter` implementations with the `IServiceCollection`\n\n   ```csharp\n   public class Startup\n   {\n       public void ConfigureServices(IServiceCollection services)\n       {\n           services.AddPageTemplateFilters(Assembly.GetExecutingAssembly());\n       }\n   }\n   ```\n\n## How Does It Work?\n\nThe `PageTypePageTemplateFilter` is simplest if your Page Templates follow some conventions, but allows for full customization.\n\nIn the example below, `Home Page (Default)` will match the filter and be allowed for selection for `Sandbox.HomePage`\nPage Types, but `Home Page (Featured)` does not have an Identifier (`Sandbox_PageTemplate_HomePage_Featured`)\nthat matches the prefix of `Sandbox.HomePage_`, so it will not be displayed for selection for\n`Sandbox.HomePage` Page Types. It would need to be changed to `Sandbox.HomePage_Featured` to match the default filter, which follows the pattern of matching Page Templates with a Identifier prefix of `$\"{PageTypeClassName}_\"`.\n\n```csharp\n[assembly: RegisterPageTemplate(\n    \"Sandbox.HomePage_Default\",\n    \"Home Page (Default)\",\n    typeof(HomePageTemplateProperties),\n    \"~/Features/Home/Sandbox.HomePage_Default.cshtml\")]\n\n[assembly: RegisterPageTemplate(\n    \"Sandbox_PageTemplate_HomePage_Featured\",\n    \"Home Page (Featured)\",\n    typeof(HomePageTemplateProperties),\n    \"~/Features/Home/Sandbox_HomePage_Featured.cshtml\")]\n\npublic class HomePageTemplateFilter : PageTypePageTemplateFilter\n{\n    public override string PageTypeClassName =\u003e HomePage.CLASS_NAME;\n}\n```\n\nThe filter can be overridden to allow you to match however you would like. It has a signature of:\n\n```csharp\nFunc\u003cPageTemplateDefinition, PageTemplateFilterContext, string, bool\u003e PageTemplateFilterBy\n```\n\nThe customization below would match an Identifier like `_Sandbox.HomePage-Default`:\n\n```csharp\npublic class HomePageTemplateFilter : PageTypePageTemplateFilter\n{\n    public override string PageTypeClassName =\u003e HomePage.CLASS_NAME;\n\n    public override Func\u003cPageTemplateDefinition, PageTemplateFilterContext, string, bool\u003e PageTemplateFilterBy { get; } =\n        (definition, context, className) =\u003e definition.Identifier.StartsWith($\"_{className}-\", StringComparison.OrdinalIgnoreCase);\n}\n```\n\nWe could even skip using the `className` entirely and match against the `definition` or `context` with some hardcoded values,\nbut at that point it's probably best to implement the `IPageTemplateFilter` directly.\n\n## Troubleshooting\n\n### InvalidOperationException: The view on path `'~/Views/Shared/PageTypes/\u003cClassName\u003e.cshtml'` could not be found and there is no page template registered for selected page\n\n#### Live Site\n\nThis error is caused by the `CMS_Document.DocumentPageTemplateConfiguration` column not being populated for the Page you are trying to display.\n\n`'~/Views/Shared/PageTypes/\u003cClassName\u003e.cshtml'` is the default path for Basic (\"Route-to-View\") [Content Tree Routing](https://docs.xperience.io/developing-websites/implementing-routing/content-tree-based-routing/setting-up-content-tree-based-routing#Settingupcontenttreebasedrouting-BasicSettingupbasicrouting). Xperience uses this View path when no `[RegisterPageRoute]` attributes are found and the Page has no Page Template configuration.\n\nIf this error occurs on the Live Site, you need to update this column with a value that looks like the following:\n\n```json\n{\n  \"identifier\": \"\u003cPageTemplateIdentifier\u003e\",\n  \"properties\": {}\n}\n```\n\nYou can expose the `DocumentPageTemplateConfiguration` column in your Page \"Content\" tab by [adding it as a Page field to the Page's Page Type](https://docs.xperience.io/developing-websites/defining-website-content-structure/managing-page-types/creating-page-types#Creatingpagetypes-Step4–Fields) using a Text Area Form Control. After you add the value (and publish the Page if it's under workflow) you can remove the field from the Page Type.\n\n#### Administration\n\nIf this error _only_ appears when trying to view the Page in the Page Builder, it means you have [Page versioning enabled](https://docs.xperience.io/x/9Q_RBg) and the value of the Page's \"Document\" fields in the `CMS_VersionHistory` table do not have a populated `DocumentPageTemplateConfiguration`. You should follow the steps in [the Live Site instructions](#live-site) and Save/Publish the latest version of the Page with the `DocumentPageTemplateConfiguration` populated.\n\n## Contributing\n\nTo build this project, you must have v6.0.300 or higher\nof the [.NET SDK](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) installed.\n\nIf you've found a bug or have a feature request, please [open an issue](https://github.com/wiredviews/xperience-page-template-utilities/issues/new) on GitHub.\n\nIf you'd like to make a contribution, you can create a [PR on GitHub](https://github.com/wiredviews/xperience-page-template-utilities/compare).\n\n## References\n\n### Kentico Xperience\n\n- [Kentico Xperience Design Patterns: MVC is Dead, Long Live PTVC](https://dev.to/seangwright/kentico-xperience-design-patterns-mvc-is-dead-long-live-ptvc-4635#building-pages-with-page-templates)\n- [Filtering Page Templates](https://docs.xperience.io/developing-websites/page-builder-development/developing-page-templates/filtering-page-templates)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwiredviews%2Fxperience-page-template-utilities","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwiredviews%2Fxperience-page-template-utilities","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwiredviews%2Fxperience-page-template-utilities/lists"}