Coilpack Documentation

website·Indexed 30 days ago

https://expressionengine.github.io/coilpack-docs/

Documentation for Coilpack, providing guides on ExpressionEngine templates, fieldtypes (such as Grid, Fluid, and Relationship), and tags including Structure Nav and Channel Entries.

Tokens
20K
Snippets
148
Records
173
Agent score
75%

What's inside Coilpack

  1. Overview of Coilpack for ExpressionEngine

    Coilpack is a Composer package that integrates ExpressionEngine into a standard Laravel application. It allows developers to use the Laravel ecosystem to manage ExpressionEngine content and services. Key features include:

    • Support for Twig and Blade for many ExpressionEngine tags.
    • Translation of ExpressionEngine Extension Hooks into Laravel Events.
    • A GraphQL endpoint for querying ExpressionEngine content.
    • Direct access to the ExpressionEngine container within Laravel.
    • Native availability of ExpressionEngine authenticated members within Laravel.
  2. Iterate over Fluid field rows in Twig or Blade

    When iterating over a Fluid field, each row acts as a field. You can access metadata about the field type and name using specific attributes to control the display logic. Available variables include _field_type and _field_name for quick identification, or accessing the field and group objects for more detail.
    {% for row in entry.fluid_field %}
        Field Value: {{ row }}
    
        Field Type: {{ row._field_type }} or {{ row.field.field_type }}
        Field Name: {{ row._field_name }} or {{ row.field.field_name }}
        Group Name: {{ row._field_name }} or {{ row.group.short_name }}
    
        Field (when row is a field): {{ row.field }}
        Group (when row is a field group): {{ row.group }}
    
        Condition for fields - {% if row.field %} ... {% endif %}
        Condition for field groups - {% if row.group %} ... {% endif %}
    {% endfor %}
  3. Ensure ExpressionEngine Add-on compatibility with Coilpack and GraphQL

    Coilpack provides automatic compatibility for many ExpressionEngine add-ons, but some may require custom handlers for tags or fieldtypes to work correctly. Specifically, to support GraphQL, custom handlers are required because GraphQL requires a strongly typed schema, whereas ExpressionEngine and PHP are loosely typed.
  4. Retrieve and display content with the Channel Entries tag

    The {exp:channel:entries} tag is the primary tool for retrieving and displaying content created in the ExpressionEngine Control Panel. It supports both multi-entry lists and single-entry displays.

    Important Coilpack Note: In Twig, Blade, or GraphQL contexts, Coilpack handles this tag differently than native ExpressionEngine: the dynamic parameter is false by default, and pagination is handled via Laravel's Pagination library.

    {exp:channel:entries}
        {title}
    {/exp:channel:entries}
  5. Understand Coilpack request routing priority

    Coilpack bootstraps ExpressionEngine inside a Laravel application. When a request is made, Laravel evaluates its own routes first. If a request matches a Laravel route, Laravel handles it. If no Laravel route matches, Coilpack passes the request to ExpressionEngine to be routed according to ExpressionEngine's templates and route definitions. You can view defined Laravel routes using php artisan route:list.
  6. Execute custom queries using the Coilpack database connection

    Coilpack establishes a dedicated MySQL database connection named coilpack using the existing ExpressionEngine configuration values. You can perform custom database operations against this connection using the Laravel DB Facade.
    \Illuminate\Support\Facades\DB::connection('coilpack')->table('channel_entries')->select('entry_id')->take(10)->get();