Admin plugin route

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 年 前
Yes, I can change my admin url.  (in the future I may also add a public part)
I'll try it out.  Thanks
12 年 前
Geralt,
I finally got back to this.  Your 5-part url works!   Thanks.
12 年 前
Hi All

As per above discussions, I rewrite my route to
routes.MapRoute("Plugin.Orders.LineItems.List","Admin/Plugins/LineItems/Admin/List",
                 new { controller = "LineItems", action = "List" },
                 new[] { "Nop.Plugin.Orders.LineItems.Controllers" }
            ).DataTokens.Add("Area", "Admin");
            

But now its hiving me an error ;
[HttpException (0x80004005): A public action method 'RssHeaderLink' was not found on controller 'Nop.Admin.Controllers.NewsController'.]
   System.Web.Mvc.Controller.HandleUnknownAction(String actionName) +146
   System.Web.Mvc.Controller.ExecuteCore() +133
   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.Mvc.<>c__DisplayClassa.<EndProcessRequest>b__9() +23
   System.Web.Mvc.<>c__DisplayClass4.<Wrap>b__3() +12
   System.Web.Mvc.ServerExecuteHttpHandlerWrapper.Wrap(Func`1 func) +38

[HttpException (0x80004005): Execution of the child request failed. Please examine the InnerException for more information.]
   System.Web.Mvc.ServerExecuteHttpHandlerWrapper.Wrap(Func`1 func) +110
   System.Web.Mvc.ServerExecuteHttpHandlerWrapper.Wrap(Action action) +65
   System.Web.Mvc.ServerExecuteHttpHandlerAsyncWrapper.EndProcessRequest(IAsyncResult result) +71
   System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride) +1072

[HttpException (0x80004005): Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'.]
   System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride) +3058371
   System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage) +77
   System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm) +28
   System.Web.HttpServerUtilityWrapper.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm) +22
   System.Web.Mvc.Html.ChildActionExtensions.ActionHelper(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues, TextWriter textWriter) +497
   System.Web.Mvc.Html.ChildActionExtensions.Action(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues) +88
   System.Web.Mvc.Html.ChildActionExtensions.Action(HtmlHelper htmlHelper, String actionName, String controllerName) +10
   ASP._Page_Views_Shared__Root_cshtml.Execute() in c:\Work\Anju\Projects\nopCommerce_2.20_Source\Presentation\Nop.Web\Views\Shared\_Root.cshtml:39
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +272
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +81
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +187
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer) +52
   System.Web.WebPages.<>c__DisplayClass7.<RenderPageCore>b__6(TextWriter writer) +203
   System.Web.WebPages.HelperResult.WriteTo(TextWriter writer) +42
   System.Web.WebPages.WebPageExecutingBase.WriteTo(TextWriter writer, HelperResult content) +45
   System.Web.WebPages.WebPageBase.Write(HelperResult result) +48
   System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action`1 body) +178
   System.Web.WebPages.WebPageBase.PopContext() +338
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +196
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer) +52
   System.Web.WebPages.<>c__DisplayClass7.<RenderPageCore>b__6(TextWriter writer) +203
   System.Web.WebPages.HelperResult.WriteTo(TextWriter writer) +42
   System.Web.WebPages.WebPageExecutingBase.WriteTo(TextWriter writer, HelperResult content) +45
   System.Web.WebPages.WebPageBase.Write(HelperResult result) +48
   System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action`1 body) +178
   System.Web.WebPages.WebPageBase.PopContext() +338
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +196
   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

Someone please help me ...
12 年 前
Try adding the admin layout to the top of your view if it's not already there...

@{
    Layout = "~/Administration/Views/Shared/_AdminLayout.cshtml";
}
12 年 前
Thanks alot for the quick response.. I was able to fix that issue the same way you suggested :) .

Now I am using Telerik.Web.Mvc.UI.MenuItemBuilder to build menu Item for My admin plugin. But I actually want to add my menu Item under 'Sales' menu which is coded in sitemap.xml. Is it possible to do it within my plugin?

Thanks in advance
12 年 前
Although I bet just editing the sitemap.xml file would work, I'm sure you want to do everything from within your plugin. Saying that, I have never tried to add a new menu item to an existing admin section, so I'm unsure how you would do that within your plugin. I have only used the menuItemBuilder to add it to the plugin dropdown.

Maybe someone else that has done this before could jump in.
12 年 前
Thought I'd try my luck here with another routing question before making another thread.

So far no issues since I started using the 5 part url discussed in this thread... having said that... In trying to add a standard delete button to my plugin in the edit view, it seems I can't figure out a way to get the Html.DeleteConfirmation helper extension to use the url format my plugin can understand.

The url I am trying to generate is "Admin/Plugin/Dealer/Admin/Delete/#"

Example 1:
@Html.DeleteConfirmation("dealer-delete")
creates the url of "/Admin/DealerAdmin/Delete/#"

Example 2:
@Html.DeleteConfirmation("Plugin/Dealer/Admin/Delete", "dealer-delete")
creates the url of "/Admin/DealerAdmin/Plugin/Dealer/Admin/Delete/#"

Which is close, but not exact. The DealerAdmin is the name of the controller in this case, and I can't seem to find a way to get it from being used. My temporary fix was just to add a new maproute to match with the extended delete url that included the controller name, but it seems very wrong to make a new route just for this one delete action.

Looking at one of the SevenSpikes plugins, it seems to use the format in Example 1, yet the plugin itself uses a 5 part url (viewing the page source I see "/admin/Plugins/SevenSpikes/HomePageSlidersAdmin/Edit?id=#" vs "/Admin/HomePageSlidersAdmin/Delete/#"), so I have no idea what wizard like magic they are using to do what I am trying to also accomplish. :)
12 年 前
So I found another way to use the Html.DeleteConfirmation extension without adding a new map route just for a single delete call (as noted in the post right above this one)

From within my plugin, I just made a new 3 parameter DeleteConfirmation as noted:
public static MvcHtmlString DeleteConfirmation<T>(this HtmlHelper<T> helper, string actionName, string controllerName, string buttonsSelector = null) where T : BaseNopEntityModel
This way I can use a 5 part admin url.
@Html.DeleteConfirmation("Delete", "Plugin/Dealer/Admin", "dealer-delete")
And it will resolve as:

/Admin/Plugin/Dealer/Admin/Delete/#

Still I'm thinking, there has to be easier way to do this, and I'm just missing something.
12 年 前
Anyone any suggestions on adding new menu item from 'Sales' dropdown menu.
As I want to do everything within my plugin , i dont want to edit sitemap.xml.

Thanks in advance
12 年 前
For those interested in extending the admin menu without editing the sitemap.xml, I just found an example of how to do so. Have your plugin class implement the IAdminMenuPlugin interface, and add the following method for starters.


public class MyPlugin : BasePlugin, IMiscPlugin, IAdminMenuPlugin
{
...
       public virtual void BuildMenuItem(Telerik.Web.Mvc.UI.MenuItemBuilder menuItemBuilder)
       {
              menuItemBuilder.Text("Plugin 1 (With image)").Url("/Link-to").ImageUrl("http://demos.telerik.com/aspnet-mvc/Content/Common/Icons/Suites/rep.png");
       }
}
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.