Skip to content

Placed the related posts list as a block scoped by path visibility. - #306

Merged
AlexSkrypnyk merged 3 commits into
developfrom
feature/related-posts-block
Aug 12, 2026
Merged

Placed the related posts list as a block scoped by path visibility.#306
AlexSkrypnyk merged 3 commits into
developfrom
feature/related-posts-block

Conversation

@AlexSkrypnyk

@AlexSkrypnyk AlexSkrypnyk commented Aug 11, 2026

Copy link
Copy Markdown
Member

Checklist before requesting a review

  • Subject includes ticket number as [#123] Verb in past tense.
  • Ticket number #123 added to description
  • Added context in Changed section
  • Self-reviewed code and commented in commented complex areas.
  • Added tests for fix/feature.
  • Relevant tests run and passed locally.

Changed

  1. Replaced the per-post Automated list paragraph with a civictheme_component_block named "Related posts" (fixed UUID c1c2b47c-4c96-4f9e-9b6e-2b1f5f3d7e10) holding a single Automated list paragraph with field_c_p_list_topics_from_page on; config/default/block.block.drevops_related_posts.yml places it in the content_bottom region of the drevops theme at weight -1 (above the Signup block), gated by one request_path visibility condition listing /blog/* and /services/*, since visibility conditions are ANDed and a Content type condition alongside a path condition would match nothing.
  2. Added do_base_deploy_add_related_posts_block(), which creates the block content against the fixed UUID and skips when it already exists, and do_base_deploy_remove_related_lists(), which detaches and deletes the page-topics Automated lists that used to sit directly on blog posts (24 real posts locally), using its own entity query as the idempotency guard.
  3. drevops_preprocess_paragraph__civictheme_automated_list() now also clears vertical_spacing on an empty result, so a page whose topics nothing else shares collapses to zero height instead of leaving a 48px gap.
  4. Moved field_c_p_list_topics_from_page into group_filters (Content tab → Filters) at weight 45, so "Use topics of the current page" renders directly under "Exposed filters" instead of floating outside the tabs.
  5. Renamed tests/behat/features/paragraph_civictheme_automated_list_related.feature to tests/behat/features/block_related_posts.feature and rewrote it: it no longer attaches a paragraph per node, and adds scenarios for the block reaching /services/* pages and staying off pages outside the visibility list.
  6. Documented the new placement model in docs/related-content.md under a "One block, placed by path" section.

Screenshots

Related posts block rendering at the foot of a blog post

The "Use topics of the current page" toggle now under Filters in the Automated list form

Before / After

BEFORE: one Automated list paragraph glued onto every blog post
┌──────────────────────────────────────────────────────────────────┐
│ node/123 (blog) .. node/999 (blog)     <- 24 posts locally, each
│   field_c_n_components                    carrying its own copy
│     └─ paragraph: civictheme_automated_list
│          field_c_p_list_topics_from_page = 1
│
│ /services/* pages                      <- never reached; nothing
│                                            was ever placed there
└──────────────────────────────────────────────────────────────────┘
        do_base_deploy_add_related_lists() seeded one per post

AFTER: one block, placed once, scoped by path
┌──────────────────────────────────────────────────────────────────┐
│ block_content: civictheme_component_block "Related posts"
│   uuid c1c2b47c-4c96-4f9e-9b6e-2b1f5f3d7e10
│     └─ paragraph: civictheme_automated_list
│          field_c_p_list_topics_from_page = 1
│
│ block.block.drevops_related_posts
│   region: content_bottom (drevops theme), weight -1
│   visibility: request_path = /blog/*, /services/*  <- both reached
└──────────────────────────────────────────────────────────────────┘
   do_base_deploy_add_related_posts_block()  creates it once
   do_base_deploy_remove_related_lists()     strips the 24 old ones

Summary by CodeRabbit

  • New Features

    • Added a Related posts block to blog and service pages.
    • Related posts are based on shared topics and remain hidden on other page types.
    • Added a page-topic filter option for automated lists.
  • Bug Fixes

    • Empty automated lists now remove unnecessary titles, rows, and vertical spacing.
    • Improved layout spacing for three-column blog content.
    • Standardized automated-list pagination heading markup.
  • Documentation

    • Updated related-content guidance, visibility rules, placement, and empty-result behavior.

@AlexSkrypnyk AlexSkrypnyk added the AUTOMERGE Pull request has been approved and set to automerge label Aug 11, 2026
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 620957d1-e65b-43df-8e42-796360d5563a

📥 Commits

Reviewing files that changed from the base of the PR and between c78e6c6 and 794e0eb.

📒 Files selected for processing (8)
  • config/default/block.block.drevops_related_posts.yml
  • config/default/core.entity_form_display.paragraph.civictheme_automated_list.default.yml
  • config/default/core.entity_view_display.node.blog.default.yml
  • config/default/views.view.civictheme_automated_list.yml
  • docs/related-content.md
  • tests/behat/features/block_related_posts.feature
  • web/modules/custom/do_base/do_base.deploy.php
  • web/themes/custom/drevops/includes/automated_list.inc

📝 Walkthrough

Walkthrough

The PR replaces per-post related-list injection with a UUID-addressed Related posts block. It updates automated-list configuration, empty-list spacing, deployment migration, documentation, and Behat coverage for blog and service paths.

Changes

Related posts

Layer / File(s) Summary
Block configuration and empty-list rendering
config/default/block.block.drevops_related_posts.yml, config/default/core.entity_form_display.paragraph.civictheme_automated_list.default.yml, config/default/core.entity_view_display.node.blog.default.yml, config/default/views.view.civictheme_automated_list.yml, web/themes/custom/drevops/includes/automated_list.inc
Adds the Related posts block and its path visibility rules. Exposes page-topic filtering. Sets pager and layout options. Clears vertical spacing when no rows render.
Block deployment and post cleanup
web/modules/custom/do_base/do_base.deploy.php
Creates the published block once by fixed UUID. Removes existing page-topic related-list paragraphs from blog posts in batches.
Behavior documentation and acceptance coverage
docs/related-content.md, tests/behat/features/block_related_posts.feature
Documents the shared block and empty-list behavior. Tests rendering on blog and service paths, no-topic results, and hidden paths.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Visitor
  participant RelatedPostsBlock
  participant AutomatedList
  participant Content
  Visitor->>RelatedPostsBlock: request blog or service page
  RelatedPostsBlock->>AutomatedList: render page-topic list
  AutomatedList->>Content: find posts with matching topics
  Content-->>AutomatedList: matching rows or empty result
  AutomatedList-->>Visitor: render Related posts or clear empty output
Loading

Possibly related PRs

Suggested labels: A2

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/related-posts-block

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 phpcs (3.13.6)
web/modules/custom/do_base/do_base.deploy.php

ERROR: Referenced sniff "Drupal" does not exist.
ERROR: Referenced sniff "DrupalPractice" does not exist.
ERROR: Referenced sniff "PHPCompatibility" does not exist.
ERROR: Referenced sniff "DrevOps" does not exist.
ERROR: Referenced sniff "SlevomatCodingStandard.TypeHints.DNFTypeHintFormat" does not exist.
ERROR: Referenced sniff "Drupal.Arrays.Array.LongLineDeclaration" does not exist.
ERROR: Referenced sniff "DrupalPractice.General.ClassName.ClassPrefix" does not exist.

Run "phpcs --help" for usage information


Comment @coderabbitai help to get the list of available commands.

@github-actions

This comment has been minimized.

@codecov-commenter

codecov-commenter commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.51%. Comparing base (c78e6c6) to head (794e0eb).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #306   +/-   ##
========================================
  Coverage    84.51%   84.51%           
========================================
  Files           26       26           
  Lines          562      562           
========================================
  Hits           475      475           
  Misses          87       87           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@AlexSkrypnyk AlexSkrypnyk added the Needs review Pull request needs a review from assigned developers label Aug 12, 2026
@AlexSkrypnyk
AlexSkrypnyk merged commit 6382ee8 into develop Aug 12, 2026
4 of 5 checks passed
@AlexSkrypnyk
AlexSkrypnyk deleted the feature/related-posts-block branch August 12, 2026 00:42
@github-actions

Copy link
Copy Markdown

Code coverage (threshold: 80%)

  Classes: 48.00% (12/25)
  Methods: 73.42% (58/79)
  Lines:   87.77% (653/744)
Per-class coverage
Drupal\do_ai_alt_text\AltTextGenerator
  Methods:  85.71% ( 6/ 7)   Lines:  98.72% ( 77/ 78)
Drupal\do_ai_alt_text\Plugin\Action\RegenerateImageAltText
  Methods: 100.00% ( 8/ 8)   Lines: 100.00% ( 63/ 63)
Drupal\do_base\EventSubscriber\PreviewLinkCacheSubscriber
  Methods:  33.33% ( 1/ 3)   Lines:  11.11% (  1/  9)
Drupal\do_base\EventSubscriber\ThemeColorSubscriber
  Methods:  66.67% ( 2/ 3)   Lines:  40.00% (  4/ 10)
Drupal\do_base\Hook\AutomatedListPagerHook
  Methods: 100.00% ( 5/ 5)   Lines: 100.00% ( 31/ 31)
Drupal\do_base\Hook\MetatagsAlterHook
  Methods: 100.00% ( 7/ 7)   Lines: 100.00% ( 58/ 58)
Drupal\do_base\Twig\ImageDimensionsExtension
  Methods:  40.00% ( 2/ 5)   Lines:  81.48% ( 44/ 54)
Drupal\do_content_api\EventSubscriber\JsonApiWriteGateSubscriber
  Methods:  66.67% ( 2/ 3)   Lines:  88.89% (  8/  9)
Drupal\do_content_api\Hook\EntityCreateAccessHook
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 12/ 12)
Drupal\do_content_api\Hook\ModerationPolicyHook
  Methods:  50.00% ( 1/ 2)   Lines:  93.75% ( 15/ 16)
Drupal\do_content_api\Routing\RouteSubscriber
  Methods: 100.00% ( 1/ 1)   Lines: 100.00% (  6/  6)
Drupal\do_feed\FeedUrlBuilder
  Methods: 100.00% ( 4/ 4)   Lines: 100.00% ( 18/ 18)
Drupal\do_feed\Form\FeedSettingsForm
  Methods: 100.00% ( 4/ 4)   Lines: 100.00% ( 15/ 15)
Drupal\do_feed\Hook\EntityDeleteHook
  Methods:  50.00% ( 1/ 2)   Lines:  92.31% ( 12/ 13)
Drupal\do_feed\Hook\EntityPresaveHook
  Methods: 100.00% ( 4/ 4)   Lines: 100.00% ( 54/ 54)
Drupal\do_feed\Hook\PreprocessParagraphHook
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 14/ 14)
Drupal\do_feed\Hook\PreprocessViewsViewRowRssHook
  Methods: 100.00% ( 1/ 1)   Lines: 100.00% (  3/  3)
Drupal\do_feed\Hook\ViewsPreViewHook
  Methods:  50.00% ( 1/ 2)   Lines:  96.43% ( 27/ 28)
Drupal\do_generated_content\Generator\CaseMatrix
  Methods: 100.00% ( 3/ 3)   Lines: 100.00% ( 12/ 12)
Drupal\do_generated_content\Generator\RelativeDate
  Methods: 100.00% ( 1/ 1)   Lines: 100.00% (  1/  1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AUTOMERGE Pull request has been approved and set to automerge Needs review Pull request needs a review from assigned developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants