Problem/Motivation
On #3090659: Make a way for help topics to generate links only if they work and are accessible, we are adding two new functions for making links in help topics.
Related change record is https://www.drupal.org/node/3192582
Once that is committed (this issue is postponed until then), we need to fix up all of the existing help topics to use the new functions.
As an example, this is how the block.place.html.twig file was updated in the patch on that issue (that was the only production topic that was updated):
-{% set configure = render_var(url('help.help_topic', {'id': 'block.configure'})) %}
+{% set configure_topic = render_var(help_topic_link('block.configure')) %}
...
- <li>{% trans %}In the <em>Manage</em> administrative menu, navigate to <em>Structure</em> > <a href="{{ layout_url }}"><em>Block layout</em></a>.{% endtrans %}</li>
+ <li>{% trans %}In the <em>Manage</em> administrative menu, navigate to <em>Structure</em> > {{ layout_link }}.{% endtrans %}</li>
...
- <li>{% trans %}Configure the block and click <em>Save block</em>; see <a href="{{ configure }}">Configuring a previously-placed block</a> for configuration details.{% endtrans %}</li>
+ <li>{% trans %}Configure the block and click <em>Save block</em>; see {{ configure_topic }} for configuration details.{% endtrans %}</li>
Steps to reproduce
N/A
Proposed resolution
- [done]
Make sure that the help topics standards on https://www.drupal.org/docs/develop/documenting-your-project/help-topic-... are updated to use the new functions. - Fix up the rest of the topics in core/modules/help_topics/help_topics to use the new help function help_topic_link (help_topic_route is on #3215784: [META] Fix up topics to use new help_route_link function
Remaining tasks
Make a patch, review, and commit.
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
Not necessary. This is an Experimental module.
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | interdiff_3192585_19-21.txt | 8.05 KB | ankithashetty |
| #21 | 3192585-21.patch | 82.29 KB | ankithashetty |
Comments
Comment #2
jhodgdonParent issue committed -- time to work on this!
Comment #3
jhodgdonAdding related issue link
Comment #4
andypostre-parented as previous parent closed
Comment #5
andypostadded CR to summary https://www.drupal.org/node/3192582
Comment #6
andypostFirst part - conversion for
help_topic_link()(few places require URL so just renamed variable)Also patch trying to use consistent naming
Comment #7
jhodgdonThanks! I just updated the standards page with the new information. https://www.drupal.org/docs/develop/managing-a-drupalorg-theme-module-or...
The patch mostly looks good!
I think we can probably update the text so that we can always say something like "See [topic name] for more information", rather than making links where we inject the URL but use other link text.
We should also avoid saying "See the [topic name] topic for more information", in my opinion, such as this in book.adding.html.twig:
Should just be
(see {{ configuring_topic }} for more information)I like the ones that say "Follow the steps in [topic_link]" too.
So, I think the following topics need attention in the patch to remove "the" or to use topic links instead of topic URLs:
I haven't tested the patch.
You mentioned in Slack that we should consider dividing this into two pieces, one for topic links and one for route links. That seems like a decent idea, except that the patches would conflict... so, either way!
Comment #8
amber himes matzI'm reviewing #3094482: Convert action module hook_help() to topic(s), including views bulk operations and also working on a new patch for it. One of the things I'm doing is adding links that use the new
help_topic_link()function for the topics in that patch. What I noticed is that if the module that provides the help topic being linked isn't installed, the link text is replaced by plain text,Missing help topic. Is there any sane way to display plain text with the title of the help topic instead of "Missing help topic"? Is there a parameter available? I have only been using the Help Topics Standards and this CR as a reference.Comment #9
jhodgdonThere is not a parameter. Adding one might be a good idea... but then again "missing help topic" might be better than "See Title of Help Topic for more information" if the topic doesn't exist? I think it could be confusing to see text implying that link if it isn't a link.
Comment #10
amber himes matzI think the situation I was running into was a bit of a chicken and egg situation. I've attached a screenshot of the page before I went with another approach (adding an "Additional resources" section). You can see how in this case "Missing help topic" isn't really helpful in this context.
Anyway, I don't want to derail this issue -- I just ran into this when using help_topic_link() and wondered if I was missing something here.
Comment #11
jhodgdonI'll take a look at the other patch, but it just occurred to me that you could do something like this for a link to a topic in another module that might not be installed:
Comment #12
andypostInteresting to check if there's something in watchdog when topic is missing...
The failed message could provide a topic ID to help find what is missing
Comment #13
amber himes matzI think this was the error message. Copied the traced until it hit the HelpTopicPluginController.
TypeError: Argument 1 passed to Drupal\help_topics\HelpTwigExtension::getTopicLink() must be of the type string, null given, called in /var/www/html/sites/default/files/php/twig/607653b04a1f0_action.overview.html.twig_bplZe_pZ85OIjtOM9gco-RuGq/Rgnx-chqgVZgDEjmK4YrDtlSVCOA8INuApJqwV3fxMc.php on line 47 in Drupal\help_topics\HelpTwigExtension->getTopicLink() (line 135 of /var/www/html/core/modules/help_topics/src/HelpTwigExtension.php)
#0 /var/www/html/sites/default/files/php/twig/607653b04a1f0_action.overview.html.twig_bplZe_pZ85OIjtOM9gco-RuGq/Rgnx-chqgVZgDEjmK4YrDtlSVCOA8INuApJqwV3fxMc.php(47): Drupal\help_topics\HelpTwigExtension->getTopicLink(NULL)
#1 /var/www/html/vendor/twig/twig/src/Template.php(405): __TwigTemplate_1821e9c34d40db56e588fa52216b2ab2518a3cc6db0b38db0af3f7223d082b30->doDisplay(Array, Array)
#2 /var/www/html/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling(Array, Array)
#3 /var/www/html/vendor/twig/twig/src/Template.php(390): Twig\Template->display(Array)
#4 /var/www/html/vendor/twig/twig/src/TemplateWrapper.php(45): Twig\Template->render(Array, Array)
#5 /var/www/html/core/modules/help_topics/src/HelpTopicTwig.php(65): Twig\TemplateWrapper->render()
#6 /var/www/html/core/modules/help_topics/src/Controller/HelpTopicPluginController.php(79): Drupal\help_topics\HelpTopicTwig->getBody()
#7 [internal function]: Drupal\help_topics\Controller\HelpTopicPluginController->viewHelpTopic('action.overview')
Comment #14
amber himes matzI don't think that's the correct watchdog message. I will recreate the problem on a fresh install and try again with the error message.
Comment #15
andypost@Amber I mean kinda this patch, probably makes sense to display the missing topic ID
Comment #16
jhodgdonI'm in favor of #15. Maybe we should make a separate issue to do it?
Comment #18
andypostFiled follow-up for #15 #3213022: When generating link to non-existent help topic, put topic ID in fallback text
Comment #19
andypostFix #7 and checked all topics - all links to topics now using
help_topic_linkAlso used to change "see {{ topic }} as suggested so needs review for interdiff
Filed follow-up to convert
urltohelp_route_link#3215784: [META] Fix up topics to use new help_route_link functionComment #20
amber himes matzLooking pretty good! A few must-fix grammar issues. Because of the way some topic link tokens are embedded in sentences, the resulting sentence ends up being unclear or grammatically incorrect/confusing. Also, some grammar nit-picks which aren't as critical.
Grammar nit. Suggestion:
Grammar nit. Suggestion:
Grammar nit. Suggestion:
The grammar doesn't work out with this particular topic link token. It renders as "The core software allows you to Configuring workflows in which each transition has an associated permission that can be granted to a particular role."
I suggest changing to:
Same with this line. The resulting grammar ("Users with sufficient permissions can use Moving content between workflow states.") makes the statement unclear. I suggest changing to:
Comment #21
ankithashettyUpdated patch in #19 addressing suggestions made in #20, thanks!
Comment #22
amber himes matzThank you @ankithashetty! I've reviewed the interdiff in #21 and all my suggestions were addressed. Great! Patch in #21 applies cleanly to a fresh clone of 9.3.x. I also checked to make sure no help topic links were missed. This looks ready to go.
Comment #23
larowlanThe proposed resolution has 3 action items, but it looks like item 3 is not yet complete?
Comment #24
jhodgdonOh sorry! We will do the third item on the other issue that was split off: #3215784: [META] Fix up topics to use new help_route_link function and it will probably also get split into its own issue there.
Comment #25
jhodgdonI spun off the tests into their own issue: #3219923: Add tests to enforce correct use of help_topic_link and help_route_link functions
Comment #26
andypostThe only question left here is should we add a check to render related topics into https://git.drupalcode.org/project/drupal/-/blob/9.3.x/core/modules/help...
Comment #27
jhodgdonNot sure what you're asking in #26, but does that question belong on the related Tests issue (see #25)?
Comment #28
andypostI mean this tests also should change the controller to prevent display of related topics which will be not accessible when related help topics will point to disabled modules (when topics will live outside of help module - in every core module)
Comment #29
jhodgdonI'm pretty sure these tests already exist.
Comment #31
larowlanApplied this locally and compared the changes with git word diff.
Committed d596833 and pushed to 9.3.x. Thanks!
As help topics is experimental, backported to 9.2.x
Thanks folks, this is a nice cleanup
Comment #32
andypostThank you! the last one is #3215784-23: [META] Fix up topics to use new help_route_link function