一键导入
drupal-paragraphs
Drupal Paragraphs module — accessing paragraph entities, rendering, altering paragraph forms, and patterns for custom paragraph behavior.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Drupal Paragraphs module — accessing paragraph entities, rendering, altering paragraph forms, and patterns for custom paragraph behavior.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | drupal-paragraphs |
| description | Drupal Paragraphs module — accessing paragraph entities, rendering, altering paragraph forms, and patterns for custom paragraph behavior. |
use Drupal\paragraphs\Entity\Paragraph;
// Get all paragraphs from a field
$items = $node->get('field_content')->referencedEntities();
foreach ($items as $paragraph) {
/** @var \Drupal\paragraphs\Entity\Paragraph $paragraph */
$bundle = $paragraph->bundle();
$value = $paragraph->get('field_text')->value;
}
// Get first paragraph
$paragraph = $node->get('field_content')->first()?->entity;
$paragraph = Paragraph::create([
'type' => 'text_block',
'field_title' => 'My Title',
'field_body' => [
'value' => 'Body content',
'format' => 'basic_html',
],
]);
$paragraph->save();
$node->get('field_content')->appendItem([
'target_id' => $paragraph->id(),
'target_revision_id' => $paragraph->getRevisionId(),
]);
$node->save();
#[Hook('field_widget_single_element_paragraphs_form_alter')]
public function fieldWidgetParagraphsFormAlter(array &$element, FormStateInterface $form_state, array $context): void {
$paragraph = $element['#paragraph'];
if ($paragraph->bundle() === 'text_block') {
// Alter the text_block paragraph form element.
$element['subform']['field_title']['#access'] = FALSE;
}
}
// Build render array for a paragraph
$view_builder = $this->entityTypeManager->getViewBuilder('paragraph');
$build = $view_builder->view($paragraph, 'default');
{# Render paragraph field #}
{{ content.field_content }}
{# Iterate paragraphs #}
{% for item in content.field_content['#items'] %}
{{ item.entity.field_text.value }}
{% endfor %}
foreach ($node->get('field_content')->referencedEntities() as $paragraph) {
/** @var \Drupal\paragraphs\Entity\Paragraph $paragraph */
switch ($paragraph->bundle()) {
case 'text_block':
// Handle text block.
break;
case 'image_block':
// Handle image block.
break;
}
}
HTMX in Drupal 11.3+ core — the Htmx PHP fluent builder, dynamic forms with swapOob, partial routes with _htmx_route, response headers, and Drupal.behaviors integration. Use when building interactive UI without full-page reloads using Drupal's native HTMX support.
DDEV local development expertise. Use when working with DDEV projects, containers, configuration, or troubleshooting DDEV environments.
Custom Docker Compose local development patterns. Use when working with Docker-based local environments, container configuration, or troubleshooting Docker setups.
Drupal access control — permissions.yml, access callbacks, AccessResult, custom access checkers, and entity access.
Drupal Cache API — cache tags, contexts, max-age, cache bins, invalidation, and adding cache metadata to render arrays.
Drupal Composer management — requiring modules, updates, patches via composer-patches, and version constraints.