Admin Template for the Plugin

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
Hi guys,

I'm writing a plugin in NopCommerce 2.1. I'm wondering if there is a way that I can force a view page within the plugin to use the _AdminLayout.cshtml instead of the _Root.cshtml? Is it possible?

Thank you in advanced
12 years ago
Note that the plugin is attached to Widget to display the PublicInfo.cshtml on the user view. However, I like to have a full Configuration page within the Admin view (not use ChildActionOnly).

Let me know if this is possible. Thanks guy
12 years ago
triho wrote:
Note that the plugin is attached to Widget to display the PublicInfo.cshtml on the user view. However, I like to have a full Configuration page within the Admin view (not use ChildActionOnly).

Let me know if this is possible. Thanks guy


In the child action view you could add a html link to the new full page view you want (or use javascript to automatically redirect). In a new full page view you would use the following code at the top of the view to get the same theme as the administration console.


@{
    Layout = "~/Administration/Views/Shared/_AdminLayout.cshtml";
}
12 years ago
skyler.severns wrote:
Note that the plugin is attached to Widget to display the PublicInfo.cshtml on the user view. However, I like to have a full Configuration page within the Admin view (not use ChildActionOnly).

Let me know if this is possible. Thanks guy

In the child action view you could add a html link to the new full page view you want (or use javascript to automatically redirect). In a new full page view you would use the following code at the top of the view to get the same theme as the administration console.


@{
    Layout = "~/Administration/Views/Shared/_AdminLayout.cshtml";
}

Thanks for your quick reply. This is the error I received

Server Error in '/' Application.

The partial view 'Menu' was not found or no view engine supports the searched locations. The following locations were searched:
~/Themes/DeepSkyBlue/Views/Banners/Menu.cshtml
~/Themes/DeepSkyBlue/Views/Banners/Menu.vbhtml
~/Themes/DeepSkyBlue/Views/Shared/Menu.cshtml
~/Themes/DeepSkyBlue/Views/Shared/Menu.vbhtml
~/Views/Banners/Menu.cshtml
~/Views/Banners/Menu.vbhtml
~/Views/Shared/Menu.cshtml
~/Views/Shared/Menu.vbhtml

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The partial view 'Menu' was not found or no view engine supports the searched locations. The following locations were searched:
~/Themes/DeepSkyBlue/Views/Banners/Menu.cshtml
~/Themes/DeepSkyBlue/Views/Banners/Menu.vbhtml
~/Themes/DeepSkyBlue/Views/Shared/Menu.cshtml
~/Themes/DeepSkyBlue/Views/Shared/Menu.vbhtml
~/Views/Banners/Menu.cshtml
~/Views/Banners/Menu.vbhtml
~/Views/Shared/Menu.cshtml
~/Views/Shared/Menu.vbhtml

Source Error:


Line 77:             {
Line 78:                 <div class="header-menu">
Line 79:                     @Html.Partial("Menu")
Line 80:                 </div>
Line 81:             }

Source File: c:\Users\Tri\Documents\Koneka\Koneka\NopCommerce\Main\Presentation\Nop.Web\Administration\Views\Shared\_AdminLayout.cshtml    Line: 79

Stack Trace:


[InvalidOperationException: The partial view 'Menu' was not found or no view engine supports the searched locations. The following locations were searched:
~/Themes/DeepSkyBlue/Views/Banners/Menu.cshtml
~/Themes/DeepSkyBlue/Views/Banners/Menu.vbhtml
~/Themes/DeepSkyBlue/Views/Shared/Menu.cshtml
~/Themes/DeepSkyBlue/Views/Shared/Menu.vbhtml
~/Views/Banners/Menu.cshtml
~/Views/Banners/Menu.vbhtml
~/Views/Shared/Menu.cshtml
~/Views/Shared/Menu.vbhtml]
   System.Web.Mvc.HtmlHelper.FindPartialView(ViewContext viewContext, String partialViewName, ViewEngineCollection viewEngineCollection) +386082
   System.Web.Mvc.HtmlHelper.RenderPartialInternal(String partialViewName, ViewDataDictionary viewData, Object model, TextWriter writer, ViewEngineCollection viewEngineCollection) +266
   System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) +113
   System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName) +31
   ASP._Page_Administration_Views_Shared__AdminLayout_cshtml.Execute() in c:\Users\Tri\Documents\Koneka\Koneka\NopCommerce\Main\Presentation\Nop.Web\Administration\Views\Shared\_AdminLayout.cshtml:79
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +207
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +81
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +88
   System.Web.WebPages.<>c__DisplayClass7.<RenderPageCore>b__6(TextWriter writer) +102
   System.Web.WebPages.HelperResult.WriteTo(TextWriter writer) +12
   System.Web.WebPages.WebPageBase.Write(HelperResult result) +67
   System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action`1 body) +66
   System.Web.WebPages.WebPageBase.PopContext() +262
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +95
   System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +220
   System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +115
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +303
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
   System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +23
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +260
   System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +19
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +177
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
   System.Web.Mvc.Controller.ExecuteCore() +116
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
   System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
   System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
   System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
   System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8963149
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.237

The URL that I'm accessing is /Plugins/Banners.

It seems not to be able to render other views properly. The View which it is accessing comes from the Controller of the plugin which is outside of the Admin project.

Am I doing it a right way?
12 years ago
skyler.severns wrote:
Note that the plugin is attached to Widget to display the PublicInfo.cshtml on the user view. However, I like to have a full Configuration page within the Admin view (not use ChildActionOnly).

Let me know if this is possible. Thanks guy

In the child action view you could add a html link to the new full page view you want (or use javascript to automatically redirect). In a new full page view you would use the following code at the top of the view to get the same theme as the administration console.


@{
    Layout = "~/Administration/Views/Shared/_AdminLayout.cshtml";
}



I mislead you :(. In version 2.2 this will be available, but you can make the modification mentioned in the post below and it will work. I've been running with this modification since the post and I forgot that others do not have it yet. Sorry!

https://www.nopcommerce.com/boards/t/11429/using-admin-theme-from-within-a-plugin-v20.aspx
12 years ago
skyler.severns wrote:
Note that the plugin is attached to Widget to display the PublicInfo.cshtml on the user view. However, I like to have a full Configuration page within the Admin view (not use ChildActionOnly).

Let me know if this is possible. Thanks guy

In the child action view you could add a html link to the new full page view you want (or use javascript to automatically redirect). In a new full page view you would use the following code at the top of the view to get the same theme as the administration console.


@{
    Layout = "~/Administration/Views/Shared/_AdminLayout.cshtml";
}



I mislead you :(. In version 2.2 this will be available, but you can make the modification mentioned in the post below and it will work. I've been running with this modification since the post and I forgot that others do not have it yet. Sorry!

https://www.nopcommerce.com/boards/t/11429/using-admin-theme-from-within-a-plugin-v20.aspx


It works like a charm. Thanks so much :)
12 years ago
skyler.severns wrote:
Note that the plugin is attached to Widget to display the PublicInfo.cshtml on the user view. However, I like to have a full Configuration page within the Admin view (not use ChildActionOnly).

Let me know if this is possible. Thanks guy

In the child action view you could add a html link to the new full page view you want (or use javascript to automatically redirect). In a new full page view you would use the following code at the top of the view to get the same theme as the administration console.


@{
    Layout = "~/Administration/Views/Shared/_AdminLayout.cshtml";
}



I mislead you :(. In version 2.2 this will be available, but you can make the modification mentioned in the post below and it will work. I've been running with this modification since the post and I forgot that others do not have it yet. Sorry!

https://www.nopcommerce.com/boards/t/11429/using-admin-theme-from-within-a-plugin-v20.aspx


Also, all of the links in the menu appear to be not Admin/Category but becomes /Category.

In the RouteProvider, when I tried to map Admin/Plugins/Banners to my Controller and the corresponding action with the area = Admin. It seems not be able to figure out the Route. However, when I map Plugins/Banners, it works fine. Then all the links in the menu are not Admin/Category but only /Catergoy -> fail to open the correct path

Here is the code of my RouteProvider.cs

    public partial class RouteProvider : IRouteProvider
    {
        public void RegisterRoutes(RouteCollection routes)
        {
            routes.MapRoute("Plugin.Koneka.Banners.Configure",
                 "Admin/Plugins/Banners",
                 new { controller = "Banners", action = "Configure", area = "Admin" },
                 new[] { "Nop.Plugin.Koneka.Banners.Controllers" }
            );
        }
        public int Priority
        {
            get
            {
                return 1;
            }
        }
    }


Any thoughts? Thanks in advance :)
12 years ago
Hi,

dou you found an solution ?

I have the same Problem.

THX

Peysche
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.