{{ document.layout }} – Extend Layout

The {{ document.layout }} function allows you to embed one layout inside another, including all associated JavaScript and CSS resources. When a layout is included, its styles and scripts are automatically added to the <head> section of the HTML document.

All Twig tags present in the included layout’s CSS and JavaScript scripts will be processed

Usage:

{{ document.layout("Layout Name") }}

Parameters:

  1. Layout Name  – The name of the layout to include.

Example:

{{ document.layout("my_script_layout") }}

Catalog Page Behavior

When used within a Catalog Page layout, this extension functions similarly to Simple Catalog Layout blocks. It will:

  • Insert catalog items using the selected layout
  • Process each item through the specified layout template
  • Behave equivalently to the following Simple Catalog Layout structure:
{% block record %}
{# Content of the specified layout will be applied to each catalog item #}
the content of "my_script_layout" layout
{% endblock %}


What are your feelings

Leave a Reply

Updated on January 20, 2025