Skip to content

Overview Block

The Overview block (Elgentos\PrismicIO\Block\Overview) provides functionality for displaying lists or collections of Prismic documents.

Features

  • Fetches multiple documents of the same type
  • Supports filtering and sorting
  • Handles language fallbacks
  • Manages document merging

Implementation

Core Methods

public function getDocuments(): array
public function getDocumentsWithoutLanguage(): array
public function buildFilters(): array
public function buildQuery(): array
public function mergeDocuments(\stdClass ...$allDocuments): array

Configuration

<block class="Elgentos\PrismicIO\Block\Overview" name="blog.list">
    <arguments>
        <argument name="document_type" xsi:type="string">blog_post</argument>
    </arguments>
</block>

Usage Examples

Basic Document List

/** @var $block \Elgentos\PrismicIO\Block\Overview */
foreach ($block->getDocuments() as $document) {
    // Process each document
}

Filtered List

$block->setAllowedFilters([
    'category' => 'my.blog_post.category'
]);

Custom Options

$block->setOptions([
    'pageSize' => 10,
    'orderings' => '[document.first_publication_date desc]'
]);

Best Practices

  1. Performance
  2. Use appropriate page sizes
  3. Implement caching where possible
  4. Consider lazy loading

  5. Language Handling

  6. Use proper language fallbacks
  7. Handle missing translations
  8. Consider multi-store setups

  9. Query Building

  10. Keep filters simple
  11. Use meaningful predicates
  12. Document query structure