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> &gt; <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> &gt; {{ 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

  1. [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.
  2. 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.

Comments

jhodgdon created an issue. See original summary.

jhodgdon’s picture

Status: Postponed » Active

Parent issue committed -- time to work on this!

jhodgdon’s picture

Adding related issue link

andypost’s picture

Issue summary: View changes
andypost’s picture

Status: Active » Needs review
StatusFileSize
new82.44 KB

First part - conversion for help_topic_link() (few places require URL so just renamed variable)

Also patch trying to use consistent naming

jhodgdon’s picture

Issue summary: View changes
Status: Needs review » Needs work

Thanks! 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:

(see the {{ configuring_topic }} topic for more information)

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:

  • book.adding.html.twig
  • content_moderation.configuring_workflows.html.twig -- suggest moving the topic link to the end of the sentence with "See ..." instead of making "entity types" the link as it is now [this applies to several of the other topics below]
  • core.media.html.twig
  • core.web_services.html.twig
  • editor.overview.html.twig -- first topic link is using the full link as the href= attribute, oops!
  • help.help_topic_search.html.twig
  • media.media_type.html.twig
  • system.module_uninstall.html.twig
  • workflows.overview.html.twig

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!

amber himes matz’s picture

I'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.

jhodgdon’s picture

There 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.

amber himes matz’s picture

Issue summary: View changes
StatusFileSize
new14.16 KB

I 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.

The text Missing help topic displayed where a topic title should be

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.

jhodgdon’s picture

I'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:

{% set topic_title_text %}
{% trans %}Configuring a foo bar{% endtrans %}
{% endset %}
{% set topic_link = render_var(help_route_link(topic_title_text, 'help.help_topic', {'id': 'other_module.foo_bar'})) %}
andypost’s picture

Interesting 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

amber himes matz’s picture

I 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')

amber himes matz’s picture

I 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.

andypost’s picture

StatusFileSize
new562 bytes

@Amber I mean kinda this patch, probably makes sense to display the missing topic ID

jhodgdon’s picture

I'm in favor of #15. Maybe we should make a separate issue to do it?

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

andypost’s picture

andypost’s picture

Title: Fix up topics to use new link functions » Fix up topics to use new help_topic_link function
Issue summary: View changes
Status: Needs work » Needs review
Related issues: +#3215784: [META] Fix up topics to use new help_route_link function
StatusFileSize
new18.66 KB
new82.18 KB

Fix #7 and checked all topics - all links to topics now using help_topic_link

Also used to change "see {{ topic }} as suggested so needs review for interdiff

Filed follow-up to convert url to help_route_link #3215784: [META] Fix up topics to use new help_route_link function

amber himes matz’s picture

Status: Needs review » Needs work

Looking 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.

  1. +++ b/core/modules/help_topics/help_topics/book.adding.html.twig
    @@ -7,12 +7,12 @@ related:
    +  <li>{% trans %}In the <em>Manage</em> administrative menu, navigate to <em>Content</em> &gt; <a href="{{ node_add }}"><em>Add content</em></a> &gt; <em>Book page</em>. If you have configured additional content types that can be added to books, you can substitute a different content type for <em>Book page</em> (see {{ configuring_topic }} for more information).{% endtrans %}</li>
    

    Grammar nit. Suggestion:

    <li>{% trans %}In the <em>Manage</em> administrative menu, navigate to <em>Content</em> &gt; <a href="{{ node_add }}"><em>Add content</em></a> &gt; <em>Book page</em>. If you have configured additional content types that can be added to books, you can substitute a different content type for <em>Book page</em>; see {{ configuring_topic }} for more information.{% endtrans %}</li>
    
  2. +++ b/core/modules/help_topics/help_topics/search.overview.html.twig
    @@ -28,7 +28,7 @@ related:
    +<p>{% trans %}In order to configure site search using the core Search module, you will need to configure one or more search pages. You will also need to verify or alter permissions so that the desired user roles can search the site (see {{ user_overview_topic }} for more information about roles and permissions). For content search, you will also need to make sure that the search index is configured and that the site is fully indexed. Finally, you may wish to place the <em>Search form</em> block on pages of your site, or add the search page to a navigation menu, to give users easy access to search. See the related topics listed below for specific tasks.{% endtrans %}</p>
    

    Grammar nit. Suggestion:

    <p>{% trans %}In order to configure site search using the core Search module, you will need to configure one or more search pages. You will also need to verify or alter permissions so that the desired user roles can search the site. (See {{ user_overview_topic }} for more information about roles and permissions.) For content search, you will also need to make sure that the search index is configured and that the site is fully indexed. Finally, you may wish to place the <em>Search form</em> block on pages of your site, or add the search page to a navigation menu, to give users easy access to search. See the related topics listed below for specific tasks.{% endtrans %}</p>
    
  3. +++ b/core/modules/help_topics/help_topics/views_ui.edit.html.twig
    @@ -5,14 +5,14 @@ related:
    +  <li>{% trans %}Find the section whose settings you want to change, such as <em>Format</em> or <em>Filter criteria</em> (see {{ views_overview_topic }} for more information).{% endtrans %}</li>
    

    Grammar nit. Suggestion:

    <li>{% trans %}Find the section whose settings you want to change, such as <em>Format</em> or <em>Filter criteria</em>. (See {{ views_overview_topic }} for more information.){% endtrans %}</li>
    
  4. +++ b/core/modules/help_topics/help_topics/workflows.overview.html.twig
    @@ -4,12 +4,12 @@ top_level: true
    +<p>{% trans %}The core software allows you to {{ configuring_workflows_topic }} in which each transition has an associated permission that can be granted to a particular role.{% endtrans %}</p>
    

    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:

    <p>{% trans %}The core software allows you to configure workflows in which each transition has an associated permission that can be granted to a particular role. See {{ configuring_workflows_topic }} for more information.{% endtrans %}</p>
    
  5. +++ b/core/modules/help_topics/help_topics/workflows.overview.html.twig
    @@ -4,12 +4,12 @@ top_level: true
    +<p>{% trans %}Users with sufficient permissions can use {{ changing_states_topic }}.{% endtrans %}</p>
    

    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:

    <p>{% trans %}Users with sufficient permissions can change the workflow state of a particular entity. See {{ changing_states_topic }} for more information.{% endtrans %}</p>
    
ankithashetty’s picture

Status: Needs work » Needs review
StatusFileSize
new82.29 KB
new8.05 KB

Updated patch in #19 addressing suggestions made in #20, thanks!

amber himes matz’s picture

Status: Needs review » Reviewed & tested by the community

Thank 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.

larowlan’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs issue summary update

The proposed resolution has 3 action items, but it looks like item 3 is not yet complete?

jhodgdon’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs issue summary update

Oh 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.

jhodgdon’s picture

andypost’s picture

The 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...

jhodgdon’s picture

Not sure what you're asking in #26, but does that question belong on the related Tests issue (see #25)?

andypost’s picture

I 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)

jhodgdon’s picture

I'm pretty sure these tests already exist.

  • larowlan committed ae9445c on 9.2.x
    Issue #3192585 by andypost, ankithashetty, Amber Himes Matz: Fix up...
  • larowlan committed d596833 on 9.3.x
    Issue #3192585 by andypost, ankithashetty, Amber Himes Matz: Fix up...
larowlan’s picture

Version: 9.3.x-dev » 9.2.x-dev
Status: Reviewed & tested by the community » Fixed

Applied 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

andypost’s picture

Status: Fixed » Closed (fixed)

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