Block should only display if "display a table of contents" checkbox is checked

Created on 23 May 2022, over 2 years ago
Updated 30 August 2024, 4 months ago

Problem/Motivation

When leveraging the "per node" option for TOC, the TOC conditionally displays based on the "display a table of contents" checkbox on individual nodes. I expected the block version of the TOC to work in same way; however, the block displays even if the "display a table of contents" box is unchecked.

I'm uncertain if this should be considered a bug, or if it's working this way by design, so I'm adding this as a feature request (please feel free to change if incorrect).

Steps to reproduce

1. Enable table of contents on a content type and check the box for "Permit to enable/disable toc per node".
3. Place the TOC JS block.
4. Add a couple pages (same content type step #1); one with "display a table of contents" checked, and one without it checked.
5. Note that TOC displays on both pages.

Proposed resolution

Add a check for the TOC block so that when the "per node" option is leveraged, the block only displays when a node has the "display a table of contents" checkbox checked.

✨ Feature request
Status

Fixed

Version

2.0

Component

User interface

Created by

πŸ‡ΊπŸ‡ΈUnited States azslay

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡·πŸ‡ΊRussia ilya.no

    ilya.no β†’ made their first commit to this issue’s fork.

  • @ilyano opened merge request.
  • Status changed to Needs review almost 2 years ago
  • πŸ‡·πŸ‡ΊRussia ilya.no

    I've created MR with this feature. Initially I tried to use hook_block_access in toc_js_per_node.module file, but it doesn't work for node pages, rendered with layout builder β†’ , so I added function blockAccess and it works fine.

  • Status changed to Needs work over 1 year ago
  • πŸ‡«πŸ‡·France flocondetoile Lyon

    This feature should be configurable at the block level (default disabled to respect current behavior) with a checkbox added on the configuration form (support_toc_js_per_node for example) if the submodule is enabled.

    Also
    $value = $node->get('toc_js_active')->first()->get('value')->getValue();

    could be simplified
    $value = $node->get('toc_js_active')->value;

  • First commit to issue fork.
  • Status changed to Needs review about 1 year ago
  • Implemented the code entirely in the toc_js_per_node for better code modularity and to avoid redundant configurations if the site doesn't make use of the per node behaviour.

    As well as supporting two different use cases with the field:

    1. Hide the block if "display a table of contents" is check (since it might be rendered using the Node view display rather than the block).
    2. Hide/show exclusively using the value of "display a table of contents". So that it acts as a way of opting in/out of the rendering
  • Updated the logic for the "hide" behaviour, such that if there's been a value set on the content in some way, that should take precedence over the block settings, and be always hidden since its being rendered on the Node display level.

    If we need other variations of logic, then we can always add more options to the list.

  • πŸ‡«πŸ‡·France mably

    FYI I think it has been implemented in the new 3.0.x-dev version.

  • Status changed to Fixed 4 months ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024