Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Merge requests
!6392
Resolve
#3418138
"More options for"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Resolve
#3418138
"More options for"
issue/drupal-3418138:3418138-more-options-for
into
10.2.x
Overview
0
Commits
2
Pipelines
2
Changes
1
Open
Paul Sheldrake
requested to merge
issue/drupal-3418138:3418138-more-options-for
into
10.2.x
1 year ago
Overview
0
Commits
2
Pipelines
2
Changes
1
Expand
Closes
#3418138
Adds more options to the Book Navigation block
0
0
Merge request reports
Compare
10.2.x
version 1
a90e07e9
1 year ago
10.2.x (HEAD)
and
latest version
latest version
ae35c437
2 commits,
1 year ago
version 1
a90e07e9
1 commit,
1 year ago
1 file
+
23
−
2
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
core/modules/book/src/Plugin/Block/BookNavigationBlock.php
+
23
−
2
Options
@@ -99,6 +99,8 @@ public function blockForm($form, FormStateInterface $form_state) {
$options
=
[
'all pages'
=>
$this
->
t
(
'Show block on all pages'
),
'book pages'
=>
$this
->
t
(
'Show block only on book pages'
),
'primary book page'
=>
$this
->
t
(
'Show block only on the top level book page'
),
'child book pages'
=>
$this
->
t
(
'Show block only on child book pages'
),
];
$form
[
'book_block_mode'
]
=
[
'#type'
=>
'radios'
,
@@ -128,6 +130,7 @@ public function build() {
if
(
$node
instanceof
NodeInterface
&&
!
empty
(
$node
->
book
[
'bid'
]))
{
$current_bid
=
$node
->
book
[
'bid'
];
}
if
(
$this
->
configuration
[
'block_mode'
]
==
'all pages'
)
{
$book_menus
=
[];
$pseudo_tree
=
[
0
=>
[
'below'
=>
FALSE
]];
@@ -169,12 +172,30 @@ public function build() {
// Only show the block if the user has view access for the top-level node.
if
(
$nid
)
{
$node
=
$this
->
routeMatch
->
getParameter
(
'node'
);
$current_nid
=
$node
->
id
();
$tree
=
$this
->
bookManager
->
bookTreeAllData
(
$node
->
book
[
'bid'
],
$node
->
book
);
// There should only be one element at the top level.
$data
=
array_shift
(
$tree
);
$primary_book_nid
=
array_pop
(
$nid
);
$below
=
$this
->
bookManager
->
bookTreeOutput
(
$data
[
'below'
]);
if
(
!
empty
(
$below
))
{
return
$below
;
if
(
$this
->
configuration
[
'block_mode'
]
==
'primary book page'
)
{
if
(
$current_nid
===
$primary_book_nid
)
{
return
$below
;
}
}
elseif
(
$this
->
configuration
[
'block_mode'
]
==
'child book pages'
)
{
if
(
$current_nid
!==
$primary_book_nid
)
{
return
$below
;
}
}
else
{
// All book pages.
if
(
!
empty
(
$below
))
{
return
$below
;
}
}
}
}
Loading