Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Kevin Jump 2324 posts 14788 karma points MVP 8x c-trib
    Mar 21, 2021 @ 12:20
    Kevin Jump
    0

    How do you tell what menu you are rendering from a MenuRenderingNotification

    When you use the NotficationHandler method to hook into the menu rendering event.

    builder.AddNotificationHandler<MenuRenderingNotification, LinkedPagesNotificationHandler>();
    

    with :

    public void Handle(MenuRenderingNotification notification)
    {
          /// add menu items here
    }
    

    how do you tell what menu you are on (e.g content, media, settings, etc?)

    under v8 you would get the tree alias in sender so could check

    if (sender.TreeAlias.InvariantEquals("content")) 
    

    . but i can't find the equivalent in the info passed in the MenuRenderingNotification model.

    so ?

    • is it there?
    • do i have to register a different way?
  • Bjarke Berg 29 posts 265 karma points hq
    Mar 21, 2021 @ 12:27
    Bjarke Berg
    1

    Seems like information has been lost doing the migration. I will add it in a PR.

  • Bjarke Berg 29 posts 265 karma points hq
    Mar 21, 2021 @ 13:03
    Bjarke Berg
    1

    The TreeAlias has been added in this PR: https://github.com/umbraco/Umbraco-CMS/pull/10024

    If you find other missing information in events, feel free to raise them on the issue tracker. The idea is to have all into on the notification, instead of both a sender and event args..

Please Sign in or register to post replies

Write your reply to:

Draft