Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional target='_blank' to the Menus and AdminMenus #15541

Closed
hyzx86 opened this issue Mar 18, 2024 · 5 comments · Fixed by #15636
Closed

Add optional target='_blank' to the Menus and AdminMenus #15541

hyzx86 opened this issue Mar 18, 2024 · 5 comments · Fixed by #15636
Milestone

Comments

@hyzx86
Copy link
Contributor

hyzx86 commented Mar 18, 2024

In some cases we need to always open external links in new pages

@hyzx86 hyzx86 changed the title Add a target attribute to the Menus and AdminMenus Add a target='_blank' to the Menus and AdminMenus Mar 19, 2024
@hyzx86 hyzx86 changed the title Add a target='_blank' to the Menus and AdminMenus Add target='_blank' to the Menus and AdminMenus Mar 19, 2024
@rjpowers10
Copy link
Contributor

A way to do this directly in Orchard Core may be nice, but in the meantime you can do something like this in your code through a shape table provider. This is how I added target='_blank' to certain admin menu items.

public class Shapes : IShapeTableProvider
{
    public void Discover(ShapeTableBuilder builder)
    {
        builder.Describe("NavigationItemLink__admin")
            .OnDisplaying(displaying =>
            {
                string id = displaying.Shape.Id;
                if (id == "some_menu_id")
                {
                    displaying.Shape.Attributes.Add("target", "_blank");
                }
            });
    }
}

@Piedone
Copy link
Member

Piedone commented Mar 19, 2024

Do you mean to add an option for menu items to generate the anchor with target blank?

@hyzx86
Copy link
Contributor Author

hyzx86 commented Mar 19, 2024

Do you mean to add an option for menu items to generate the anchor with target blank?

Yes, the menu items of OC support external links, but we can only open them in the current window.

@MikeAlhayek
Copy link
Member

Adding a settings will be useful where users can alternate between _self (default), _blank, _parent, _top

@hyzx86 will you submit a PR for this?

@hyzx86
Copy link
Contributor Author

hyzx86 commented Mar 23, 2024

I'm thinking about how to design this interaction...
The average user may be overwhelmed by so many options, and if a predefined drop-down menu is used, it may not be enough for developers

hyzx86 pushed a commit to hyzx86/OrchardCore that referenced this issue Apr 1, 2024
@Piedone Piedone changed the title Add target='_blank' to the Menus and AdminMenus Add optional target='_blank' to the Menus and AdminMenus May 21, 2024
@Piedone Piedone added this to the 2.x milestone May 21, 2024
@MikeAlhayek MikeAlhayek modified the milestones: 2.x, 2.0 Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants