Skip to content

Container Block

The Container block provides a way to group and organize Prismic content blocks.

Implementation

Container Block Class

Elgentos\PrismicIO\Block\Container

Extends the abstract block to provide container functionality.

Key Features

  • Groups related content blocks
  • Manages shared context
  • Handles nested structures
  • Provides scope isolation

Usage

Basic Container

<block class="Elgentos\PrismicIO\Block\Container" name="prismic.content">
    <arguments>
        <argument name="reference" xsi:type="string">data</argument>
    </arguments>
    <!-- Child blocks -->
</block>

Nested Containers

<block class="Elgentos\PrismicIO\Block\Container" name="outer.container">
    <block class="Elgentos\PrismicIO\Block\Container" name="inner.container">
        <!-- Nested content -->
    </block>
</block>

Context Management

Reference Handling

Containers can specify their reference scope:

<arguments>
    <argument name="reference" xsi:type="string">data.section</argument>
</arguments>

Context Inheritance

Child blocks inherit their parent container's context unless explicitly overridden.

Best Practices

  1. Organization
  2. Group related content
  3. Use meaningful names
  4. Maintain clear hierarchy

  5. Performance

  6. Avoid deep nesting
  7. Consider caching strategies
  8. Monitor render times

  9. Maintenance

  10. Document container structure
  11. Keep layouts organized
  12. Use consistent patterns