Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/twistedstack/drupal-paragraph-status
Drupal module for handling status codes in a paragraph component.
https://github.com/twistedstack/drupal-paragraph-status
component drupal paragraph
Last synced: 2 days ago
JSON representation
Drupal module for handling status codes in a paragraph component.
- Host: GitHub
- URL: https://github.com/twistedstack/drupal-paragraph-status
- Owner: twistedstack
- License: gpl-3.0
- Created: 2024-12-08T10:16:48.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2024-12-08T11:41:23.000Z (about 2 months ago)
- Last Synced: 2024-12-08T12:24:44.943Z (about 2 months ago)
- Topics: component, drupal, paragraph
- Language: PHP
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# drupal-paragraph-status
Drupal module for handling status codes in a paragraph component.
**Status:** `still developing`
Drupal module that shows a particular paragraph field based on the node path.
### Explanation of the Code
1. **Path Matching Logic**:
- The `PathMatcher` service is used to determine which paragraphs to display based on the current path.2. **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.3. **Rendering Paragraphs**:
- The `entityTypeManager`'s `viewBuilder` is used to render the filtered paragraphs in the desired view mode.---
### Enable the Module
1. Place the module in the `modules/custom` directory.
2. Enable it using Drush or the admin UI:```bash
drush en custom_paragraph_display
drush cr
```---
### Test the Module
1. Create or edit a node with the specified paragraph field (`field_paragraph_content`).
2. Visit the node's path (e.g., `/special-path` or `/another-path/some-page`).
3. 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.