How to add new link in menu for new page?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Il y a 12 ans
I followed this to add new page https://www.nopcommerce.com/boards/t/10728/how-to-add-new-page-in-20.aspx#43657

how to add that new page in the menu ?

I created new resource as

ResourceName: MyCatalog
Value: Catalog

Added this in Menu.chtml

<li><a href="@Url.RouteUrl("MyCatalog")">@T("MyCatalog")</a> </li>

but i am getting this error


A route named 'MyCatalog' could not be found in the route collection.
Parameter name: name
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.ArgumentException: A route named 'MyCatalog' could not be found in the route collection.
Il y a 12 ans
Hi,

You need to change the href="@Url.RouteUrl("MyCatalog")" to your page's url (for example: href="/yourpage" or href="http://www.yourwebsite.com/yourpage")...

Esbee
Il y a 12 ans
My bad :) Didn't see on the other post that you've created a controller for this (thought you've created a "topic" page)...

I am currently writing a menu editor (will share when done):

public class MenuItem : BaseEntity {
        private ICollection<MenuItem> _menuItems;

        public virtual string Title { get; set; }
        public virtual string Slug { get; set; }
        public virtual string LinkTitle { get; set; }
        public virtual string SubText { get; set; }
        public virtual string MimeType { get; set; }
        public virtual byte[] BinaryData { get; set; }
        public virtual string IconAltTag { get; set; }
        public virtual string IconTitle { get; set; }
        public virtual int ParentItemId { get; set; }
        public virtual int DisplayOrder { get; set; }
        public virtual DateTime? PublishFrom { get; set; }
        public virtual DateTime? PublishTo { get; set; }
        public virtual int LanguageId { get; set; }

        public virtual Language Language { get; set; }
        public virtual MenuItem ParentItem { get; set; }
        public virtual ICollection<MenuItem> ChildItems {
            get { return _menuItems ?? (_menuItems = new List<MenuItem>()); }
            protected set { _menuItems = value; }
        }
    }
Il y a 12 ans
thnx will be waiting for answer.
Il y a 12 ans
1) Edit the RouteProvider.cs file in Nop.Web project
2) Add the following code:

routes.MapRoute("MyCatalog",
                            "MyCatalog" or whatever your route is,
                            new { controller = "MyCatalog", action = "Index (or whatever the name or your action is)", any additional parameter if needed },
                            new[] { "Nop.Web.Controllers" });
3) Compile


This should do...
Il y a 12 ans
Or (damn, why can't we edit posts???)

href="@Url.RouteUrl("YOURACTION*", "MyCatalog")"


* the name of the action (method) in your controller...

public ActionResult ****NAMEOFACTION****()
Il y a 12 ans
It means I need to compile everytime I make changes in menu ? like adding new links
Il y a 12 ans
this worked

<li><a href="../MyCatalog">@T("MyCatalog")</a> </li>

is this correct ? this is more simple and no recompilation
Il y a 12 ans
No, not in the menu... You don't have to compile views, only when you change files with .cs extensions...
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.