Skip to content

Commit 7ed9792

Browse files
Mile23paul-m
Mile23
authored andcommitted
Issue #2976202 by Mile23: Ensure that all description page paths are clickable
1 parent ea85fce commit 7ed9792

File tree

9 files changed

+79
-36
lines changed

9 files changed

+79
-36
lines changed

field_example/templates/description.html.twig

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ Description text for the Field Example.
44
55
#}
66

7+
{% set edit_content_types = path('entity.node_type.collection') %}
8+
79
{% trans %}
810

911
<p>The Field Example provides a field composed of an HTML RGB value, like
10-
<code>#ff00ff</code>. To use it, add the field to a content type.</p>
12+
<code>#ff00ff</code>. To use it, <a href={{ edit_content_types }}>add the
13+
field to a content type</a>.</p>
1114

1215
{% endtrans %}

field_permission_example/templates/description.html.twig

+17-13
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,25 @@
88
*/
99
#}
1010

11-
<div class='examples-description'>
11+
{% set edit_content_types = path('entity.node_type.collection') %}
12+
1213
{% trans %}
13-
<p>The Field Permission Example module shows how you can restrict view and edit permissions
14-
within your field implementation. It adds a new field type called Fieldnote. Fieldnotes
15-
appear as simple text boxes on the create/edit form, and as sticky notes when viewed.
16-
By 'sticky note' we mean 'Post-It Note' but that's a trademarked term.</p>
1714

18-
<p>To see this field in action, add it to a content type or user profile. Go to the
19-
permissions page ({{admin_link}}) and look at the 'Field Permission Example' section. This
20-
allows you to change which roles can see and edit Fieldnote fields.</p>
15+
<p>The Field Permission Example module shows how you can restrict view and edit
16+
permissions within your field implementation. It adds a new field type called
17+
Fieldnote. Fieldnotes appear as simple text boxes on the create/edit form, and
18+
as sticky notes when viewed. By 'sticky note' we mean 'Post-It Note' but that's
19+
a trademarked term.</p>
20+
21+
<p>To see this field in action, <a href={{ edit_content_types }}>add it to a
22+
content type</a> or user profile. Go to the permissions page ({{admin_link}})
23+
and look at the 'Field Permission Example' section. This allows you to change
24+
which roles can see and edit Fieldnote fields.</p>
25+
26+
<p>Creating different users with different capabilities will let you see these
27+
behaviors in action. Fieldnote helpfully displays a message telling you which
28+
permissions it is trying to resolve for the current field/user combination.</p>
2129

22-
<p>Creating different users with different capabilities will let you see these behaviors
23-
in action. Fieldnote helpfully displays a message telling you which permissions it is
24-
trying to resolve for the current field/user combination.</p>
30+
<p>Definitely look through the code to see various implementation details.</p>
2531

26-
<p>Definitely look through the code to see various implementation details.</p>
2732
{% endtrans %}
28-
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
hooks_example.description:
2+
title: Hooks Example
3+
description: Hook examples using Drupal hooks.
4+
route_name: hooks_example.description
5+
expanded: TRUE

hooks_example/hooks_example.module

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function hooks_example_help($route_name, RouteMatchInterface $route_match) {
7575
switch ($route_name) {
7676
// For help overview pages we use the route help.page.$moduleName.
7777
case 'help.page.hooks_example':
78-
return '<p>' . t('This text is provided by the function hooks_example_help(), which is an implementation of the hook hook_help(). To learn more about how this works checkout the code in hooks_example.module.') . '</p>';
78+
return '<p>' . t('This text is provided by the function <code>hooks_example_help()</code>, which is an implementation of <code>hook hook_help()</code>. To learn more about how this works checkout the code in <code>hooks_example.module</code>.') . '</p>';
7979
}
8080
}
8181

hooks_example/templates/description.html.twig

+26-13
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,40 @@ Description text for the Hooks Example.
44
55
#}
66

7+
{% set help_hooks_example = path('help.page', {'name': 'hooks_example'}) %}
8+
{% set node_add_page = path('node.add_page') %}
9+
{% set user_login = path('user.login') %}
10+
711
{% trans %}
12+
813
<h2>Implementing, defining, and invoking hooks</h2>
914

1015
<p>The code in this module implements a couple of new features which you can see
1116
in action.</p>
1217

13-
<p><strong>Implements hook_help():</strong> In hooks_example.module you'll find
14-
an implementation of the hook hook_help() which is used to add contents to this
15-
module's help overview. Visible at admin/help/hooks_example.</p>
18+
<p><strong>Implements <code>hook_help()</code>:</strong> In
19+
<code>hooks_example.module</code> you'll find an implementation of the
20+
<code>hook hook_help()</code> which is used to add contents to this module's
21+
help overview. Visible at <a href={{ help_hooks_example }}>
22+
<code>admin/help/hooks_example</code></a>.</p>
1623

17-
<p><strong>View counts:</strong> hooks_example_node_view() is an implementation
18-
of the hook hook_ENTITY_TYPE_view() that adds a basic page view counter. You can
19-
see this in action by navigating to any node on the site and looking for the the
20-
text telling you how many times you've viewed that page.</p>
24+
<p><strong>View counts:</strong> <code>hooks_example_node_view()</code> is an
25+
implementation of the hook <code>hook_ENTITY_TYPE_view()</code> that adds a
26+
basic page view counter. You can see this in action by navigating to any node on
27+
the site and looking for the the text telling you how many times you've viewed
28+
that page.</p>
2129

22-
<p><strong>Implements hook_form_alter():</strong> In hookse_example.module
23-
you'll find an implementation of hook_form_alter() which demonstrates the use of
24-
one of the most commonly used alter hooks. You can view the altered form at
25-
user/login.</p>
30+
<p>Don't have any nodes? <a href={{ node_add_page }}>Add some</a> and look at
31+
their counters.</p>
32+
33+
<p><strong>Implements <code>hook_form_alter()</code>:</strong> In
34+
<code>hooks_example.module</code> you'll find an implementation of
35+
<code>hook_form_alter()</code> which demonstrates the use of one of the most
36+
commonly used alter hooks. You can view the altered form at
37+
<a href={{ user_login }}><code>user/login</code></a>.</p>
2638

2739
<p>To learn more about how to implement an existing hook, or how to define and
28-
invoke a new hook start by reading the @docblock comments in
29-
hooks_example.module</p>
40+
invoke a new hook start by reading the <code>@docblock</code> comments in
41+
<code>hooks_example.module</code>.</p>
42+
3043
{% endtrans %}

hooks_example/tests/src/Functional/HooksExampleTest.php

+4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ public function setUp() {
4040
* Test the output of the example page.
4141
*/
4242
public function testHooksExample() {
43+
// Make sure our menus and links work.
44+
$this->drupalGet('<front>');
45+
$this->assertSession()->linkExists('Hooks Example');
46+
4347
// Test the description page at examples/hook-example returns a 200.
4448
$this->drupalGet('examples/hooks-example');
4549
$this->assertSession()->statusCodeEquals(200);

js_example/js_example.links.menu.yml

+2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ js_example.weights:
1010
description: Show list weighting through JavaScript.
1111
route_name: js_example.weights
1212
parent: js_example.info
13+
weight: 10
1314

1415
js_example.accordion:
1516
title: jQuery UI accordion
1617
description: jQuery UI accordion demo.
1718
route_name: js_example.accordion
1819
parent: js_example.info
20+
weight: 1

js_example/templates/description.html.twig

+14-8
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,26 @@ Description text for the JavaScript Example.
44
55
#}
66

7+
{% set js_weights = path('js_example.weights') %}
8+
{% set js_accordion = path('js_example.accordion') %}
9+
710
{% trans %}
811

912
<p>Drupal includes jQuery and jQuery UI.</p>
1013

1114
<p>We have two examples of using these:</p>
1215

1316
<ol>
14-
<li>
15-
<p>An accordion-style section reveal effect: This demonstrates calling a jQuery
16-
UI function using Drupal rendering system.
17-
</li>
18-
<li>
19-
<p>Sorting according to numeric weight: This demonstrates attaching your own
20-
JavaScript code to individual page elements using Drupal rendering system.</p>
21-
</li>
17+
<li>
18+
<p><a href={{ js_accordion }}>An accordion-style section reveal effect</a>:
19+
This demonstrates calling a jQuery UI function using Drupal rendering
20+
system.
21+
</li>
22+
<li>
23+
<p><a href={{ js_weights }}>Sorting according to numeric weight</a>: This
24+
demonstrates attaching your own JavaScript code to individual page
25+
elements using Drupal rendering system.</p>
26+
</li>
2227
</ol>
28+
2329
{% endtrans %}

testing_example/templates/description.html.twig

+6
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@ Description text for the PHPUnit Example.
44
55
#}
66

7+
{% set sum_in_hands = path('testing_example.sum_in_hands') %}
8+
79
{% trans %}
810
<h2>Testing Frameworks in Drupal</h2>
911

12+
<p>This module <a href={{ sum_in_hands }}>provides a path</a> so we can test it.
13+
The path takes two numeric arguments, and tells you how many hands are
14+
required to count the sum of both numbers.</p>
15+
1016
<h3>How to use this example module</h3>
1117
<p>You really should be reading the various docblocks in the files under
1218
<code>tests/src/</code>.</p>

0 commit comments

Comments
 (0)