Skip to content

Unable to create simple link in the admin menu #4941

@orchardbot

Description

@orchardbot

MauricePrather created:
https://orchard.codeplex.com/workitem/21112

Objective:
Create a menu item in the admin panel that points to a custom url. The following code is used to create a menu item in the admin panel.
builder.Add(T("Test Link"), "6",
item => item.Add(T("Configure"), "0", menuItem => menuItem.Url("http://example.com") )
);

Result:
"Test Link" appears in admin menu but it does not use an anchor tag. It's as the code puts it there to "look pretty".

Expect:
The menu item should have a link to the target url.

Faulting condition:
On line 37 of Themes/TheAdmin/Views/Menu.cshtml (version 1.8.1 code), there's the following check:
|| HasText(firstOfTheSecond.Url))) {

This check fails. Url is never populated with the correct value of the menu item. If you look at line 38, it appears the check should be against the Href property as that value contains the url specified in code and is subsequently used to create the link.

Workaround:
Change line 37to check the Href property instead of the Url property.

Broader issue:
It seems that the properties Href and Url are mixed. Some times it seems Href represents the site-relative url to the current tenant and other times it appears to be a full url (as in this case). The workaround I specified allows me to get my custom links up and running but I defer to the team to validate this is the absolute right fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions