Orchard Core - Override UserMenuItems-Profile

40 Views Asked by At

Orchard Core contains UserMenuItems views which are templates for the user profile dropdown shown below. There are various, with conditional checks to display based on user permissions.

enter image description here

I am trying to override this, as I want the UserMenuItems-Profile option to navigate to /Admin/my.theme.name/Home/Profile (Controller=Home, Action=Profile, Area=my.theme.name) instead of /Admin/Users/Edit (Controller=Admin, Action=Edit, Area=OrchardCore.Users).

UserMenuItems-Profile.cshtml

@using System.Security.Claims

@inject IAuthorizationService AuthorizationService

@if (await AuthorizationService.AuthorizeAsync(User, CommonPermissions.EditOwnUser))
{
    <li>
        <a class="dropdown-item" asp-area="OrchardCore.Users" asp-action="Edit" asp-controller="Admin" asp-route-returnUrl="@FullRequestPath">
            <i class="far fa-address-card" aria-hidden="true"></i> @T["Profile"]
        </a>
    </li>
}
else if (await AuthorizationService.AuthorizeAsync(User, CommonPermissions.ViewUsers))
{
    <li>
        <a class="dropdown-item" asp-area="OrchardCore.Users" asp-action="Display" asp-controller="Admin" asp-route-id="@User.FindFirstValue(ClaimTypes.NameIdentifier)" asp-route-returnUrl="@FullRequestPath">
            <i class="far fa-address-card" aria-hidden="true"></i> @T["Profile"]
        </a>
    </li>
}

I have attempted to override the existing UserMenuItems-Profile.cshtml file (originally located in src/OrchardCore.Modules/OrchardCore.Users/Views/UserMenuItems-Profile.cshtml) by adding a new file to my.theme.name/Views/OrchardCore.Users/UserMenuItems-Profile.cshtml.

This however doesn't seem to work, both as a module and theme. The dropdown list remains the same no matter what.

0

There are 0 best solutions below