Are there any functional reasons why these menus (see attached image) require hooks to add new items and aren't just normal drupal menus?

Comments

the_glitch created an issue. See original summary.

kingdutch’s picture

Status: Active » Needs review

Hi!

I suspect this is mostly a legacy thing. This code has existed within Open Social for a relatively long time so it's possible that whoever first build it decided that it was the best solution with the tools available in Drupal 8 at that moment.

Another good reason is that the hook implementation route means that each module has a standardised way to implement their possible addition for the menu. This ensures that new items from modules that implement content types or things that can be created are automatically picked up in the menu.

Changing this over to a menu could break existing sites that extend the system through hooks. It could also cause the site manager to inadvertently delete or duplicate navigational items that are crucial for the Open Social experience.

I hope this answers your question, please let me know if anything is unanswered/unclear.

~ Kingdutch

the_glitch’s picture

Thanks for answering that for me. As a site builder that can't program, this is going to make adding menu items difficult for me. It seems that I should probably leave these menus in the hook implementation format.

Could you, or anybody else reading this, please point me to where the code is that's responsible for the [+] menu so I can have a look and maybe work out how to add new content types to that menu?

Any other leads, tips or advice would be greatly appreciated.

kingdutch’s picture

Status: Needs review » Fixed

The entire menu (including the user profile dropdown and notification center) is build by the AccountHeaderBlock which is found in the social_user menu.

The various modules in Open Social implement the hook_social_user_account_header_create_links hook. This is documented in the social_user.api.php file.

You can also look at social_topic_social_user_account_header_create_links in the social_topic module for an example implementation. The API file still needs to be updated to use the render array pattern of the Url to automatically handle access checks. This has been done in the social_topic implementation.

Ideally modules that want to support Open Social and provide content types would simply implement this hook. It does nothing outside of Open Social so there's no harm in shipping it. Alternatively someone in the community could build a module that would implement this hook and simply translate a menu into additional items to be rendered. That could then be used by site builders.

tepelena’s picture

It's funny, I have the same issue.
Don't see why this needs to be implemented through hooks.

The best solution would be to have it a Drupal menu.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.