PartialWidgetPage.Kentico.MVC 12.29.9

Allows you to render another Page's content (including widgets)

There is a newer version of this package available.
See the version list below for details.
Install-Package PartialWidgetPage.Kentico.MVC -Version 12.29.9
dotnet add package PartialWidgetPage.Kentico.MVC --version 12.29.9
<PackageReference Include="PartialWidgetPage.Kentico.MVC" Version="12.29.9" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PartialWidgetPage.Kentico.MVC --version 12.29.9
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: PartialWidgetPage.Kentico.MVC, 12.29.9"
For F# scripts that support #r syntax, copy this into the source code to reference the package.

Partial Widget Page

This tool allows you to render out a Widget (Page Builder) Page as a Partial.

Installation

Install the Nuget Package on the MVC Site

Usage

Setup Partial-Viewable Content

On a Page with Kentico's Page Builder Enabled and an Editable Area existing, set the Layout from

Layout = "~/Views/Shared/_Layout.cshtml";

to

Layout = Html.LayoutIfEditMode("~/Views/Shared/_layout.cshtml");

This will enable the normal view to be resolved as a partial view, depending on the context. When visiting through Kentico, EditMode is enabled and the full layout will render, allowing you to add Widgets.

WARNING: INFINITE LOOPS

Do not use a Layout that renders the page you are editing in itself. This will cause an infinite loop when editing the page. If you editing a page that will be used in the Header and Footer, for example, please make a different Layout view that does not have the PartialWidgetPage Html Helpers.

Allow page to render as normal page AND Partial View

If you wish for a page to render as a full page on Live, but also still want to pull this in as a Partial in certain cases, use the following in the View:

Layout = Html.LayoutIfEditMode("~/Views/Shared/_layout.cshtml", "RenderAsPartial");

and call it using

@Html.PartialWidgetPage("/Route/To/Page", "RenderAsPartial")

(or add RenderAsPartial as the Render as Parital Url Parameter on the Partial Widget Page widget). The system will now pass this Url Parameter in it's Render Partial requests.

Showing Partial Widget Pages

There are two ways and three methods ways you can render Partial widget pages:

Methods

There are three methods, Server Request, Ajax, and Inline. Please see the readme for table, as Nuget doesn't render markdown tables properly:

Way 1: Widget

You can use the Partial Widget Page Widget to pull in content through a normal page builder widget. The widget only works with Server Request and Ajax methods.

Way 2: In Razor View

** Server Request Method**
@Html.PartialWidgetPage allows you to pull in with a Server Request
You can pass either a custom Path, or a NodeAliasPath.

** Ajax Method**
@Html.PartialWidgetPageAjax allows you to pull in with a client side Ajax Request (Ajax Method)
You can pass either a custom Path, or a NodeAliasPath.

Inline Method
In order to do the Inline method, you first must wire up the PartialWidgetPageDocumentFinder as the implementation of IPartialWidgetPageDocumentFinder, for example using AutoFac: builder.RegisterType<PartialWidgetPageDocumentFinder>().As<IPartialWidgetPageDocumentFinder>()

Then you can use any one of these methods to render by NodeGuid, NodeID, or NodeAliasPath

@* public ActionResult RenderFromViewByDocumentGuid(Guid DocumentGuid, string ControllerName, string ActionName = "Index", int? CurrentDocumentsID = null) *@
        @{ Html.RenderAction("RenderFromViewByDocumentGuid", "PartialWidgetPage", new { DocumentGuid = new Guid("f860cfbd-5423-4769-8f9d-2d2f833d9575"), ControllerName = "PartialWidgetPageTestChild", ActionName = "Index" }); }
@* public ActionResult RenderFromViewByPath(string NodeAliasPath, string ControllerName, string ActionName = "Index", string SiteName = null, string Culture = null, int? CurrentDocumentsID = null) *@
        @{ Html.RenderAction("RenderFromViewByPath", "PartialWidgetPage", new { NodeAliasPath = "Child2", ControllerName = "PartialWidgetPageTestChild", ActionName = "Index", SiteName = "Baseline", Culture = "en-US" }); }
@* public ActionResult RenderFromViewByNodeGuid(Guid NodeGuid, string ControllerName, string ActionName = "Index", string Culture = null, int? CurrentDocumentsID = null) *@
        @{ Html.RenderAction("RenderFromViewByNodeGuid", "PartialWidgetPage", new { NodeGuid = new Guid("b8dfc82d-a6bf-4d13-a723-93020e25d386"), ControllerName = "PartialWidgetPageTestChild", ActionName = "Index", Culture = "en-US" }); }

These methods render the view inline. It requires a call to an Action Method that accepts int DocumentID or int? DocumentID, as the Partial widget system will pass the documentID to that method to render. It takes care of setting the Page Builder context and resetting it after.

Here is an example method:

// GET: PartialWidgetPageTestChild
        public ActionResult Index(int? DocumentID)
        {
            if (DocumentID.HasValue)
            {
                // Rendered through Partial Widget Page, Document context already set
                return View();
            }
            else
            {
                // Rendering through normal way
                ITreeNode FoundNode = _DynamicRouteHelper.GetPage();

                if (FoundNode != null)
                {
                    HttpContext.Kentico().PageBuilder().Initialize(FoundNode.DocumentID);
                    return View();
                }
                else
                {
                    return HttpNotFound();
                }
            }
        }

Partial Widget Page

This tool allows you to render out a Widget (Page Builder) Page as a Partial.

Installation

Install the Nuget Package on the MVC Site

Usage

Setup Partial-Viewable Content

On a Page with Kentico's Page Builder Enabled and an Editable Area existing, set the Layout from

Layout = "~/Views/Shared/_Layout.cshtml";

to

Layout = Html.LayoutIfEditMode("~/Views/Shared/_layout.cshtml");

This will enable the normal view to be resolved as a partial view, depending on the context. When visiting through Kentico, EditMode is enabled and the full layout will render, allowing you to add Widgets.

WARNING: INFINITE LOOPS

Do not use a Layout that renders the page you are editing in itself. This will cause an infinite loop when editing the page. If you editing a page that will be used in the Header and Footer, for example, please make a different Layout view that does not have the PartialWidgetPage Html Helpers.

Allow page to render as normal page AND Partial View

If you wish for a page to render as a full page on Live, but also still want to pull this in as a Partial in certain cases, use the following in the View:

Layout = Html.LayoutIfEditMode("~/Views/Shared/_layout.cshtml", "RenderAsPartial");

and call it using

@Html.PartialWidgetPage("/Route/To/Page", "RenderAsPartial")

(or add RenderAsPartial as the Render as Parital Url Parameter on the Partial Widget Page widget). The system will now pass this Url Parameter in it's Render Partial requests.

Showing Partial Widget Pages

There are two ways and three methods ways you can render Partial widget pages:

Methods

There are three methods, Server Request, Ajax, and Inline. Please see the readme for table, as Nuget doesn't render markdown tables properly:

Way 1: Widget

You can use the Partial Widget Page Widget to pull in content through a normal page builder widget. The widget only works with Server Request and Ajax methods.

Way 2: In Razor View

** Server Request Method**
@Html.PartialWidgetPage allows you to pull in with a Server Request
You can pass either a custom Path, or a NodeAliasPath.

** Ajax Method**
@Html.PartialWidgetPageAjax allows you to pull in with a client side Ajax Request (Ajax Method)
You can pass either a custom Path, or a NodeAliasPath.

Inline Method
In order to do the Inline method, you first must wire up the PartialWidgetPageDocumentFinder as the implementation of IPartialWidgetPageDocumentFinder, for example using AutoFac: builder.RegisterType<PartialWidgetPageDocumentFinder>().As<IPartialWidgetPageDocumentFinder>()

Then you can use any one of these methods to render by NodeGuid, NodeID, or NodeAliasPath

@* public ActionResult RenderFromViewByDocumentGuid(Guid DocumentGuid, string ControllerName, string ActionName = "Index", int? CurrentDocumentsID = null) *@
        @{ Html.RenderAction("RenderFromViewByDocumentGuid", "PartialWidgetPage", new { DocumentGuid = new Guid("f860cfbd-5423-4769-8f9d-2d2f833d9575"), ControllerName = "PartialWidgetPageTestChild", ActionName = "Index" }); }
@* public ActionResult RenderFromViewByPath(string NodeAliasPath, string ControllerName, string ActionName = "Index", string SiteName = null, string Culture = null, int? CurrentDocumentsID = null) *@
        @{ Html.RenderAction("RenderFromViewByPath", "PartialWidgetPage", new { NodeAliasPath = "Child2", ControllerName = "PartialWidgetPageTestChild", ActionName = "Index", SiteName = "Baseline", Culture = "en-US" }); }
@* public ActionResult RenderFromViewByNodeGuid(Guid NodeGuid, string ControllerName, string ActionName = "Index", string Culture = null, int? CurrentDocumentsID = null) *@
        @{ Html.RenderAction("RenderFromViewByNodeGuid", "PartialWidgetPage", new { NodeGuid = new Guid("b8dfc82d-a6bf-4d13-a723-93020e25d386"), ControllerName = "PartialWidgetPageTestChild", ActionName = "Index", Culture = "en-US" }); }

These methods render the view inline. It requires a call to an Action Method that accepts int DocumentID or int? DocumentID, as the Partial widget system will pass the documentID to that method to render. It takes care of setting the Page Builder context and resetting it after.

Here is an example method:

// GET: PartialWidgetPageTestChild
        public ActionResult Index(int? DocumentID)
        {
            if (DocumentID.HasValue)
            {
                // Rendered through Partial Widget Page, Document context already set
                return View();
            }
            else
            {
                // Rendering through normal way
                ITreeNode FoundNode = _DynamicRouteHelper.GetPage();

                if (FoundNode != null)
                {
                    HttpContext.Kentico().PageBuilder().Initialize(FoundNode.DocumentID);
                    return View();
                }
                else
                {
                    return HttpNotFound();
                }
            }
        }

Release Notes

Fixed wrong dependency key

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
13.0.3 115 12/19/2020
13.0.2 54 12/18/2020
13.0.1 98 12/15/2020
12.29.9 116 10/2/2020
12.29.8 96 9/2/2020
12.29.7 314 6/17/2020
12.29.6 113 6/17/2020
12.29.5 147 6/15/2020
12.29.4 1,548 10/10/2019
12.29.3 227 9/20/2019
12.29.2 265 8/9/2019
12.29.1 209 8/8/2019
12.0.0.1 187 7/15/2019
12.0.0 184 7/15/2019