backdrop-contrib / examples

Examples for Developers
GNU General Public License v2.0
7 stars 9 forks source link

Fix problem with lack of Navigation Menu #106

Open stpaultim opened 2 months ago

stpaultim commented 2 months ago

The readme says

Profit! The examples would appear in your Navigation menu if there was one. (Since we've removed the navigation menu in Backdrop they won't appear anywhere until somebody updates the code.)

What does it mean, "until somebody updates the code."?

I've spend quite a bit of time tonight trying to use these modules to understand how menu items are being created. I'm tempted to try and help fix this problem, but I need some tips on what the fix is?

I guess, since there is no Navigation Menu, we need to start by deciding where these menu items should show up?

stpaultim commented 2 months ago

I took a wild guess at one possible answer for the page example module. I submitted a PR and would love some feedback. https://github.com/backdrop-contrib/examples/issues/105

avpaderno commented 2 months ago

I find that sentence a little "fuzzy": It is not clear if code needs to be changed in Backdrop core or in the Example modules.

IMO, the hook_menu() implementations done in the Example modules should use a visible menu. After all, the Example modules are... example modules. Their menus do not need to be hidden; they should be visible, as they are installed on a local site.
Once that is done, that sentence is no longer necessary.

avpaderno commented 2 months ago

While I think the routes added from the example modules should be visible in a menu, I prefer not to show them in the Primary navigation menu, where other menu items could be present. Instead, I would show them in an Examples menu create by the Examples for Developers module, which essentially is the main module for this project.

stpaultim commented 2 months ago

As for the menu not showing up, isn't this a problem with all the submodules?

Yes, to my knowledge this is a problem for all submodules. I think that the problem is that currently all submodules are creating links on this internal hidden menu and that we need to decide what the best alternative would be for Backdrop CMS.

I would prefer a page with links for each reachable page created by each submodule, but that could be my personal preference.

I'm a little unsure of exactly what you are suggesting here. Links need to appear on menus, so the question is which menu to add links for the example menu. Having these links on a page is not helpful, unless there is a link in the main menu to that page.

If you could do a PR with a example of what you have in mind that might be helpful. But, I will also try to work on a suggested solution.

@docwilmot Do you have thoughts on this?

(Responding to comments posted in: https://github.com/backdrop-contrib/examples/issues/105)

docwilmot commented 2 months ago

To get examples module links to appear in a menu, we We have two main options I can think of:

  1. We write new code in every single examples module, which is reasonable, since they are meant to be used independently.
  2. We make all the Example modules dependent on examples.module, in which case we can put code in just that module that applies to all examples.

If we choose either of the above, we could:

a. create a new menu to put example links into (this would need to be done in every single Example, if we choose 1 above) b. create a root Examples menu link in Admin Bar (although Admin Bar is already a bit crowded TBH) (this would need to be done in every single Example, if we choose 1 above) c. use an existing menu path, such as for example admin/config/development/. (same)

I'm partial to 1+C. Change all links to admin/config/development/examples and add to every Example:

  $items['admin/config/development/examples'] = array(
    'title' => 'Examples',
    'type' => MENU_DEFAULT_LOCAL_TASK,
  );

But 2+C is close too.