-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Kelly Rock edited this page Dec 8, 2024
·
3 revisions
Status: still developing
Drupal module that shows a particular paragraph field based on the node path.
-
Path Matching Logic:
- The
PathMatcher
service is used to determine which paragraphs to display based on the current path.
- The
-
Field Filtering:
- The code checks if the node has the paragraph field and retrieves referenced paragraphs.
- Depending on the path, it filters or modifies the paragraphs before rendering.
-
Rendering Paragraphs:
- The
entityTypeManager
'sviewBuilder
is used to render the filtered paragraphs in the desired view mode.
- The
- Place the module in the
modules/custom
directory. - Enable it using Drush or the admin UI:
drush en custom_paragraph_display
drush cr
- Create or edit a node with the specified paragraph field (
field_paragraph_content
). - Visit the node's path (e.g.,
/special-path
or/another-path/some-page
). - Verify that the correct paragraph(s) are displayed based on the current path.
This approach dynamically alters the rendering of the paragraph field based on the current path, offering a flexible and scalable solution.