Problem/Motivation
It's best practice for Drupal modules to provide help using hook_help() for the help.page.[module-name] path. This provides module-specific info on the core help landing page: https://www.drupal.org/documentation/modules/help
We should also add a help_example
module which demonstrates this hook and its best practices in detail.
Proposed resolution
Implement hook_help()
for each example module, for the help.page.[module-name]
path. This will provide module-specific information for the help page.
Do not add hook_help()
per controller path, because that will be confusing for anyone reading the code.
Add a help_example
module.
Remaining tasks
User interface changes
Comment | File | Size | Author |
---|---|---|---|
#9 | Add_HELP_to_Examples_for_Developers-2723625-9.patch | 3.6 KB | minakshiPh |
| |||
#7 | interdiff-2723625-2-7.txt | 3.8 KB | minakshiPh |
#7 | Add_HELP_to_Examples_for_Developers-2723625-7.patch | 3.6 KB | minakshiPh |
#2 | 2723625-Add_HELP_to_Examples_for_Developers-2.patch | 3.04 KB | dbt102 |
|
Comments
Comment #2
dbt102 CreditAttribution: dbt102 commentedComment #3
dbt102 CreditAttribution: dbt102 commentedComment #4
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedLet's have a look at this issue to avoid lots of text, did you ran it through phpcs? It might have thrown an error of coding standards related to concatenation with t() function.
See: #2660058: [meta] Convert controller content to twig {% trans/endtrans %} templates per module
Comment #5
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedComment #6
minakshiPh CreditAttribution: minakshiPh at Iksula commentedComment #7
minakshiPh CreditAttribution: minakshiPh at Iksula commentedUpdated the patch with coding standards and as mentioned in #5
Comment #9
minakshiPh CreditAttribution: minakshiPh at Iksula commentedRe-rolled the patch.
Kindly review.
Thanks!
Comment #10
dbt102 CreditAttribution: dbt102 commentedThanks for fixing up the -2 patch @minakshiPH .
The -9 patch applied cleanly. And, I looked at the code to see exactly what changes were made (just so I understand). Tested the patched module on a _dev site and the HELP section look good.
Comment #11
Mile23Thanks for working on this.
As much as possible we want to use twig translatable templates for big blocks of content like this. Examples has
Drupal\examples\Utility\DescriptionTemplateTrait
to help out with this in controllers. I'd guess it would work returning appropriate markup forhook_help()
as well.We've also historically had some conversations as to whether Examples modules should always have
hook_help()
: #2123195: [policy] Change approach on end user ui We want to err on the side of having useful explanatory content on the page, rather than relying on help text, but both could work if presented properly.If you want to talk about whether to add
hook_help()
to some or all of these modules, let's have that conversation here. Then we can open sub-issues as needed to addhook_help()
to the different modules.We should also consider adding an example of how to use hook_help(), both with and without the twig templating system.
Rescoping this issue to be a PLAN.
Comment #12
Mile23Erp... Wait a minute. I made a mistake. :-)
This sets the help displayed in the module information page, rather than the help at the top of the page. That's a great idea, and we should do that for each module.
But we definitely want to use the twig template scheme to provide this content, so that it's translatable and doesn't make the code part of the module confusing. We want minimal how-to documentation in each example module for this help system.
We also want a follow-up to make a help_example so we can provide detailed documentation for all these things in that module, without having to provide a lot of confusing documentation within all the other modules.
Thanks. :-)
Comment #13
dbt102 CreditAttribution: dbt102 commentedI agree that each of the sub-modules would be improved by adding help per the Help text standard
I'd suggest that the commit be made for the main "Examples for Developers" module (this issue) and have that serve as an example for the remaining submodules.
I think it would be less confusing if a new [meta] issue be created rather than repurposing this one. Then this one could be referenced in the meta easy enough for tracking.
Then, a new issue could be created per sub-module. I think this would break it down into manageable chunks. I'd be glad to set this up.
I'm not clear about your ideas about the twig template schemes, because the Help text standard does talk a lot about translation, but does not discuss twig template schemes. The purpose of the Help text standard, and the overview help page is different than that of highly commented code. I always go to the help overview of a module just to get clued into the basics of what the module is about and how its used.
I'd be glad to help out with the overall effort, and the could help with the twig templates once one was completed.
Since HELP should be provided by all core and contrib modules, a submodule dedicated to this makes sense too. TOURs are optional, and there is a dedicated module for that. This makes it seem more obvious that HELP submodule should be there too.