### Install Coilpack and Run Setup Wizard Source: https://context7.com/expressionengine/coilpack-docs/llms.txt Install Coilpack using Composer and configure it via the `php artisan coilpack` command. This wizard can link an existing ExpressionEngine installation or create a new one. Ensure your Laravel `.env` file is configured with database credentials and the correct `APP_URL`. ```sh # Create a new Laravel project targeting a specific version composer create-project --prefer-dist "laravel/laravel:<=11" my-project cd my-project # Require Coilpack 2.x composer require expressionengine/coilpack:2.x # Run the interactive setup wizard php artisan coilpack # -> Choose to install a new EE instance or provide a path to an existing one # Configure the Laravel .env APP_URL=https://my-project.test DB_HOST=127.0.0.1 DB_DATABASE=my_project_db DB_USERNAME=root DB_PASSWORD= # After setup, access the EE control panel at: # https://my-project.test/admin ``` -------------------------------- ### Create Astro Project Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/guides/using-graphql-astro.md Use the Astro CLI to create a new Astro project. Follow the prompts to configure your project, choosing an empty setup and installing dependencies. ```bash npm create astro@latest Where should we create your new project? # How would you like to start your new project? # Install dependencies? # Initialize a new git repository? # Do you plan to write TypeScript? # Liftoff confirmed. Explore your project! ``` ```bash cd astro-project-folder npm run dev ``` -------------------------------- ### Setup Coilpack Command Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/artisan.md Run this command to initiate the setup process for connecting ExpressionEngine with your Laravel application. ```php php artisan coilpack ``` -------------------------------- ### Start Local Development Server with Yarn Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/README.md Starts a local development server for live previewing changes. Changes are reflected without server restarts. ```bash yarn start ``` -------------------------------- ### Install Dependencies with Yarn Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/README.md Run this command to install project dependencies using Yarn. Ensure Yarn is installed globally. ```bash yarn ``` -------------------------------- ### Install Gatsby GraphQL Source Plugin Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/guides/using-graphql-gatsby.md Install the gatsby-source-graphql plugin to enable fetching data from remote GraphQL endpoints. ```bash npm install gatsby-source-graphql ``` -------------------------------- ### GraphQL API Setup and Usage Source: https://context7.com/expressionengine/coilpack-docs/llms.txt Instructions on enabling, securing, and querying Coilpack's built-in GraphQL endpoint. ```APIDOC ## GraphQL API **Enable and secure Coilpack's built-in GraphQL endpoint.** Enable GraphQL by setting `COILPACK_GRAPHQL_ENABLED=true` in `.env`. Secure the endpoint for production using a bearer token generated via Artisan. Send queries to `/graphql`; use the interactive GraphiQL explorer at `/graphiql`. ```sh # Enable GraphQL and generate a security token COILPACK_GRAPHQL_ENABLED=true COILPACK_GRAPHIQL_ENABLED=true # optional: enable browser-based explorer php artisan coilpack:graphql --generate-token # Writes COILPACK_GRAPHQL_TOKEN= to .env ``` ```sh # Query the endpoint with curl using bearer token auth curl -X POST https://my-site.test/graphql \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_GRAPHQL_TOKEN" \ -d '{ "query": "{ exp_channel_entries(channel: \"blog\", limit: 3) { data { title url_title entry_date } total } }" }' ``` ```graphql ``` ``` -------------------------------- ### Structure Navigation Parameter: start_from Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/templates/tags/structure-nav.mdx Specifies the URI from which to begin revealing child pages in the navigation. This parameter is crucial for controlling the starting point of your navigation tree. ```php start_from: "/some-url" ``` -------------------------------- ### Register Custom Files in addon.setup.php Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/advanced/addons.md Register custom tags and fieldtypes for Coilpack by adding a 'coilpack' section to your add-on's setup file. ```php return array( 'name' => 'Addon Name' 'description' => 'Addon Description' ... 'coilpack' => [ 'tags' => [ 'tagname' => 'Addon\Tags\TagName' ], 'fieldtypes' => [ 'super_checkbox' => 'Addon\Fieldtypes\SuperCheckbox' ] ] ); ``` -------------------------------- ### Comment Entries Query Example Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/graphql/queries/comment-entries.md An example of how to use the exp_comment_entries query in GraphQL, demonstrating various arguments for filtering and sorting comments. ```APIDOC ## Comment Entries Query ### Description Retrieves comment entries with various filtering and sorting options. ### Method GraphQL Query ### Endpoint N/A (GraphQL endpoint) ### Arguments - **author_id** (String) - Optional - Filter comments by author ID. - **channel** (String) - Optional - Filter comments by channel handle or ID (e.g., "channel1|channel2"). - **comment_id** (String) - Optional - Filter comments by specific comment IDs (e.g., "22"). - **dynamic** (Boolean) - Optional - Whether to use dynamic results. - **entry_id** (String) - Optional - Filter comments by entry ID, supports exclusion (e.g., "not 45|534|807"). - **entry_status** (String) - Optional - Filter comments by the status of their associated entry. - **limit** (String) - Optional - The maximum number of comments to return. - **orderby** (String) - Optional - The field to order comments by (e.g., "date"). - **site** (String) - Optional - Filter comments by site ID. - **sort** (String) - Optional - The direction of sorting (e.g., "asc", "desc"). - **status** (String) - Optional - Filter comments by their status. - **url_title** (String) - Optional - Filter comments by the URL title of their associated entry. ### Fields - **comment** (String) - The content of the comment. ### Request Example ```graphql { exp_comment_entries( author_id: "5", channel: "channel1|channel2", comment_id: "22", dynamic: true, entry_id: "not 45|534|807", entry_status: "Featured", limit: "30", orderby: "date", site: "1", sort: "asc", status: "Closed", url_title: "my_wedding" ) { comment } } ``` ### Response Example ```json { "data": { "exp_comment_entries": [ { "comment": "This is a sample comment." } ] } } ``` ``` -------------------------------- ### Manage Coilpack and ExpressionEngine via Artisan CLI Source: https://context7.com/expressionengine/coilpack-docs/llms.txt Utilize Artisan commands for Coilpack setup, GraphQL token generation, and proxying to ExpressionEngine's CLI tool. ```sh # Run the interactive Coilpack setup / re-configure an existing install php artisan coilpack # Generate (or rotate) the GraphQL bearer token and save it to .env php artisan coilpack:graphql --generate-token # Proxy to ExpressionEngine's CLI (run EE commands with Laravel context) php artisan eecli update # run an EE update php artisan eecli generate:templates # generate templates for all channels php artisan eecli cache:clear # clear the EE template cache ``` -------------------------------- ### Blade Templates Example Source: https://context7.com/expressionengine/coilpack-docs/llms.txt Demonstrates how to write ExpressionEngine templates using Laravel's Blade templating engine, including accessing global variables and EE data. ```APIDOC ## Blade Templates **Write ExpressionEngine templates using Laravel's Blade templating engine.** Create template files with the `.blade.php` extension inside `resources/views/` or inside the EE templates folder with a `.blade` suffix. The `$exp` variable is the Blade equivalent of Twig's `exp`, and `$global` provides access to EE global variables. ```php {{-- resources/views/blog/index.blade.php --}} @extends('ee::_layouts._base') @section('content')

{{ $global->site_name }}

@php $entries = $exp->channel->entries([ 'channel' => 'blog', 'limit' => 10, 'orderby' => 'entry_date', 'sort' => 'desc', 'per_page' => 5, ]); @endphp @forelse($entries as $entry)

{{ $entry->title }}

{!! $entry->page_content !!}
@empty

No entries found.

@endforelse {{ $entries->links() }} {{-- Embed a native EE partial --}} {{ $exp->embed('_partials/footer', ['year' => date('Y')]) }} @endsection ``` ``` -------------------------------- ### Basic Channel Entries Query Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/graphql/queries/channel-entries.md This example demonstrates a basic query to fetch channel entries with specific arguments like category ID, channel name, status, and pagination limits. ```APIDOC ## Basic Channel Entries Query ### Description Fetches channel entries with specified criteria. ### Query ```graphql { exp_channel_entries( category_id: "21" channel: "about" status: "open", per_page: 2 ) { data { entry_id title custom_channel_field } total per_page current_page from to last_page has_more_pages } } ``` ### Parameters - **category_id** (String) - Optional - The ID of the category to filter entries by. - **channel** (String) - Optional - The name of the channel to fetch entries from. - **status** (String) - Optional - The status of the entries to retrieve (e.g., "open", "closed"). - **per_page** (Int) - Optional - The number of entries to return per page. ### Response #### Success Response (200) - **data** (Array) - Contains the list of channel entries. - **entry_id** (String) - The unique identifier for the entry. - **title** (String) - The title of the entry. - **custom_channel_field** (String) - A custom field associated with the entry. - **total** (Int) - The total number of entries available. - **per_page** (Int) - The number of entries per page. - **current_page** (Int) - The current page number. - **from** (Int) - The starting entry number on the current page. - **to** (Int) - The ending entry number on the current page. - **last_page** (Int) - The last page number. - **has_more_pages** (Boolean) - Indicates if there are more pages available. ``` -------------------------------- ### Register Custom Tag in addon.setup.php Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/advanced/addons/tags.md Register a custom tag by including a 'coilpack' section in your add-on's setup file, mapping a tag name to its class. ```php return array( 'name' => 'Addon Name' 'description' => 'Addon Description' ... 'coilpack' => [ 'tags' => [ 'tagname' => 'Addon\Tags\TagName' ] ] ); ``` -------------------------------- ### Display Channel Categories with Pagination (Native) Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/templates/tags/channel-categories.mdx Outputs channel categories with top pagination enabled. This is the native templating engine example. ```html {exp:channel:categories paginate="top"} {category_name} {/exp:channel:categories} ``` -------------------------------- ### Listen for ExpressionEngine Core Boot Hook as Laravel Event Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/events.md Prefix ExpressionEngine hooks with 'ee:' to listen for them as Laravel events. This example shows how to listen for the 'core_boot' hook. ```php Event::listen('ee:core_boot', function() { echo '

Booting

'; }); ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/getting-started.md Update your .env file with your application URL and database connection details. These are crucial for Coilpack's setup. ```sh APP_URL=https://project-name.test DB_HOST=127.0.0.1 DB_DATABASE=project_name_database DB_USERNAME=root DB_PASSWORD= ``` -------------------------------- ### Channel Categories Tag with All Parameters (GraphQL) Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/templates/tags/channel-categories.mdx Example of using parameters in a GraphQL query for channel categories. Parameters are passed directly to the query. ```graphql { exp_channel_categories( category_id: "2|45|4|9", category: "cars|sports", channel: "channel1|channel2", group_id: "4", limit: 1, orderby: "cat_name", search: {body: "pickles"}, site: "1", sort: "asc", ) { data { cat_name } } } ``` -------------------------------- ### Structure Entries Tag Examples Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/templates/tags/structure-entries.mdx Demonstrates basic usage of the Structure Entries tag to loop through entries and display their titles. Compatible with Channel Entries tag parameters. ```php {exp:structure:entries} {title} {/exp:structure:entries} ``` ```twig {% for entry in exp.structure.entries %} {{ entry.title }} {% endfor %} ``` ```php @foreach($exp->structure->entries as $entry) {{ $entry->title }} @endforeach ``` ```graphql { exp_structure_entries { data { title } } } ``` -------------------------------- ### Render Multi Select Field Values Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/templates/fieldtypes/multi-select.mdx Display the selected options from a Multi Select field. Use the first example to render a comma-separated list of labels. The subsequent examples iterate through all available options or only the selected ones, showing their labels and values. ```twig {{ entry.multi_select_field }} ``` ```twig {% for value, label in entry.multi_select_field.options %} {{ label }} - {{ value }} {% endfor %} ``` ```twig {% for value, label in entry.multi_select_field.selected %} {{ label }} - {{ value }} {% endfor %} ``` -------------------------------- ### Access ExpressionEngine Filesystem via Laravel Storage Source: https://context7.com/expressionengine/coilpack-docs/llms.txt Use the `coilpack` storage disk to read and write files within the ExpressionEngine installation path using Laravel's Storage facade. ```php use Illuminate\Support\Facades\Storage; // Check if a file exists in the EE install $exists = Storage::disk('coilpack')->exists('index.php'); // true // Read EE user config $config = Storage::disk('coilpack')->get('system/user/config/config.php'); // List files in EE's uploads directory $uploads = Storage::disk('coilpack')->files('images/uploads'); // Write a file into the EE install path Storage::disk('coilpack')->put('system/user/cache/my-cache.json', json_encode($data)); ``` -------------------------------- ### Create Gatsby Home Page with GraphQL Query Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/guides/using-graphql-gatsby.md Create a Gatsby home page that queries ExpressionEngine channel entries and global variables using the configured GraphQL endpoint. This example fetches the site name and a list of entry titles and their URLs. ```javascript import * as React from 'react' import { graphql } from 'gatsby' const HomePage = ({ data }) => { return (

{ data.ee.variables.site_name }

    { data.ee.exp_channel_entries.data.map(entry => { return (
  • {entry.title}
  • ) })}
) } export const query = graphql ` { ee { variables{ site_name } exp_channel_entries { data { entry_id title url_title } } } } ` export default HomePage ``` -------------------------------- ### Channel Entries with Length and Chained Modifiers Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/graphql/queries/channel-entries.md This example demonstrates using the `length` modifier and chaining `limit` and `length` modifiers on a text field. ```APIDOC ## Channel Entries with Length and Chained Modifiers ### Description Fetches channel entries and applies `length` and chained `limit` and `length` modifiers to text fields. ### Query ```graphql { exp_channel_entries { entry_id title page_content(length:true) excerpt_length:page_content( limit: {characters: 10, end_char: "..."}, length: true ) } } ``` ### Modifiers - **length**: Returns the length of the field's content. - **limit**: Truncates text. Accepts an object with `characters` or `words` properties, and an optional `end_char`. ### Response #### Success Response (200) - **entry_id** (String) - The unique identifier for the entry. - **title** (String) - The title of the entry. - **page_content** (String) - The content of the page_content field, with its length indicated. - **excerpt_length** (String) - The content of the page_content field, limited and truncated, with its length indicated. ``` -------------------------------- ### Display Channel Categories with Pagination (Twig) Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/templates/tags/channel-categories.mdx Fetches and displays channel categories with pagination using Twig. This example shows how to iterate through categories and access pagination links. ```twig {% set categories = exp.channel.categories({per_page:5}) %} {% for category in categories %} {{ category.cat_name }} {% endfor %} {{ categories.links }} ``` -------------------------------- ### Channel Entries with Image Resizing Modifier Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/graphql/queries/channel-entries.md This example shows how to use the `resize` modifier on a File fieldtype within a Grid fieldtype to control image dimensions. ```APIDOC ## Channel Entries with Image Resizing Modifier ### Description Fetches channel entries and applies a resize modifier to an image field. ### Query ```graphql { exp_channel_entries { data { entry_id about_image { # File Grid fieldtype image(resize: {width:100}) { # File fieldtype url width height } caption align } } } } ``` ### Modifiers - **resize**: Modifies image dimensions. Accepts an object with `width` and `height` properties. ### Response #### Success Response (200) - **data** (Array) - Contains the list of channel entries. - **entry_id** (String) - The unique identifier for the entry. - **about_image** (Object) - Represents a Grid field containing file information. - **image** (Object) - Represents a File fieldtype with applied modifiers. - **url** (String) - The URL of the resized image. - **width** (Int) - The width of the resized image. - **height** (Int) - The height of the resized image. - **caption** (String) - The caption of the image. - **align** (String) - The alignment of the image. ``` -------------------------------- ### Comment Entries Tag with Parameters Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/templates/tags/comment-entries.mdx Demonstrates the use of various parameters with the Comment Entries tag across different templating engines. This example illustrates parameter usage for filtering and controlling output. ```php {exp:comment:entries author_id="5" channel="channel1|channel2" comment_id="22" dynamic="yes" entry_id="not 45|534|807" entry_status="Featured" limit="30" orderby="date" site="1" sort="asc" status="Closed" url_title="my_wedding" } {comment} {/exp:comment:entries} ``` ```graphql {% for entry in exp.comment.entries({ author_id: "5", channel: "channel1|channel2", comment_id: "22", dynamic: true, entry_id: "not 45|534|807", entry_status: "Featured", limit: "30", orderby: "date", site: "1", sort: "asc", status: "Closed", url_title: "my_wedding" }) %} {{ entry.comment }} {% endfor %} ``` ```php @foreach($exp->comment->entries([ "author_id" => "5", "channel" => "channel1|channel2", "comment_id" => "22", "dynamic" => true, "entry_id" => "not 45|534|807", "entry_status" => "Featured", "limit" => "30", "orderby" => "date", "site" => "1", "sort" => "asc", "status" => "Closed", "url_title" => "my_wedding" ]) as $entry) {{ $entry->comment }} @endforeach ``` ```graphql { exp_comment_entries( author_id: "5", channel: "channel1|channel2", comment_id: "22", dynamic: true, entry_id: "not 45|534|807", entry_status: "Featured", limit: "30", orderby: "date", site: "1", sort: "asc", status: "Closed", url_title: "my_wedding" ) { comment } } ``` -------------------------------- ### Astro Home Page with GraphQL Data Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/guides/using-graphql-astro.md Create an Astro page to fetch and display data using the GraphQL client. This example fetches the site name and a list of channel entries, then renders them in an HTML structure. ```jsx --- import GraphQL from '../graphql'; const data = await GraphQL.query(` { variables{ site_name } exp_channel_entries { data { entry_id title url_title } } } `); ---

{data.variables.site_name}

    { data.exp_channel_entries.data.map(entry => { return (
  • {entry.title}
  • ) })}
``` -------------------------------- ### Rendering Selectable Buttons Parameters Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/templates/fieldtypes/selectable-buttons.mdx Render the parameters for a Selectable Buttons field, such as limiting the number of selections or specifying markup. This example limits to one selection and uses an unordered list. ```twig {{ entry.buttons_field.parameters({limit: 1, markup: 'ul'}) | raw }} ``` -------------------------------- ### Display Channel Categories with Pagination (Blade) Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/templates/tags/channel-categories.mdx Retrieves and renders channel categories with pagination using Blade templating. This example demonstrates iterating over categories and using the links method for pagination. ```php @php $categories = $exp->channel->categories(["per_page" => 5]); @endphp @foreach($categories as $category) {{ $category->cat_name }} @endforeach {{ $categories->links() }} ``` -------------------------------- ### Fetch Channel Categories with Pagination (GraphQL) Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/templates/tags/channel-categories.mdx Queries channel categories using GraphQL, specifying the number of items per page. This example shows how to retrieve category data along with pagination details. ```graphql { exp_channel_categories(per_page: 5) { data { cat_name } total per_page current_page from to last_page has_more_pages } } ``` -------------------------------- ### Get Channel Entries by Channel Name Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/examples.md Fetches channel entries from a specific channel and transforms them into a desired array format. Ensure the 'news' channel exists. ```php $entries = \Expressionengine\Coilpack\Models\ChannelEntry::whereHas('channel', function($query) { return $query->where('channel_name', 'news'); })->get(); return $entries->transform(function($entry) { return [ 'title' => $entry->title, 'custom' => $entry->custom_field_name ]; }); ``` -------------------------------- ### Coilpack Configuration File (`config/coilpack.php`) Source: https://context7.com/expressionengine/coilpack-docs/llms.txt The `config/coilpack.php` file controls Coilpack's behavior, including the path to the ExpressionEngine installation, admin URL, GraphQL settings, and the custom member model. EE configuration values can be accessed via `config('coilpack.expressionengine.')`. ```php // config/coilpack.php (representative excerpt) return [ // Path to your ExpressionEngine installation 'base_path' => env('EE_BASE_PATH', base_path('ee')), // URL for the EE control panel 'admin_url' => '/admin', // Override the Eloquent model used for EE members 'member_model' => \App\Models\Member::class, 'graphql' => [ 'enabled' => env('COILPACK_GRAPHQL_ENABLED', false), 'graphiql' => env('COILPACK_GRAPHIQL_ENABLED', false), 'auth' => [ 'enabled' => env('COILPACK_GRAPHQL_AUTH_ENABLED', true), 'driver' => env('COILPACK_GRAPHQL_AUTH_DRIVER', 'token'), 'token' => env('COILPACK_GRAPHQL_TOKEN', null), ], ], ]; // Access any EE config value inside Laravel: $version = config('coilpack.expressionengine.app_version'); // Set the default template engine in EE's config.php: // system/user/config/config.php $config['default_template_engine'] = 'twig'; // or 'blade' ``` -------------------------------- ### Structure Navigation Parameter: show_depth Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/templates/tags/structure-nav.mdx Controls how many levels deep all children pages of the current 'start_from' parameter should be revealed. This parameter affects the depth of the entire navigation tree below the starting point. ```php show_depth: 3 ``` -------------------------------- ### Restrict Route to Members with Specific Permissions Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/routing.md Employ the `member_with_permission` middleware to gate routes, requiring logged-in members to possess certain ExpressionEngine permissions. Example permissions include 'can_search' and 'can_view_profiles'. ```php Route::get('search', function() { echo 'hello!'; })->middleware('member_with_permission:can_search,can_view_profiles'); ``` -------------------------------- ### Configure Multi Select Field Parameters Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/templates/fieldtypes/multi-select.mdx Control the output of the Multi Select field by passing parameters. This example demonstrates limiting the number of results and specifying the markup format (e.g., an unordered list). ```twig {{ entry.multi_select_field.parameters({limit: 1, markup: 'ul'}) }} ``` -------------------------------- ### Comment Entries Query Example Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/graphql/queries/comment-entries.md Use this query to retrieve comment entries with various filtering and sorting options. Ensure the correct argument names and values are used for accurate results. ```graphql { exp_comment_entries( author_id: "5", channel: "channel1|channel2", comment_id: "22", dynamic: true, entry_id: "not 45|534|807", entry_status: "Featured", limit: "30", orderby: "date", site: "1", sort: "asc", status: "Closed", url_title: "my_wedding" ) { comment } } ``` -------------------------------- ### Registering Custom Member Model and Sanctum Token Creation Source: https://context7.com/expressionengine/coilpack-docs/llms.txt Configuration and route examples for using a custom member model with Coilpack and Laravel Sanctum. This includes registering the model and creating a token creation route. ```php // config/coilpack.php — register the custom model 'member_model' => \App\Models\Member::class, // routes/web.php — Sanctum token creation route Route::middleware('auth:coilpack')->post('/tokens/create', function (Illuminate\Http\Request $request) { $token = $request->user('coilpack')->createToken($request->token_name); return ['token' => $token->plainTextToken]; }); // Protect a route requiring an authenticated Sanctum user Route::middleware('auth:sanctum')->get('/user', fn($request) => $request->user()); ``` -------------------------------- ### Structure Navigation Tag Parameters (Native) Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/templates/tags/structure-nav.mdx Use this tag to generate navigation menus with various customization options. It supports parameters for controlling the starting point, depth, status, and inclusion/exclusion of entries. ```php {exp:structure:nav start_from="/some-url" strict_start_from="yes" show_depth=3 max_depth=4 status="closed" include="1|3|5" exclude="2|4|6" show_expired="yes" show_future_entries="yes" override_hidden_state="yes" site_url="yes" } ``` -------------------------------- ### Rendering Selectable Buttons Parameters (Blade) Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/templates/fieldtypes/selectable-buttons.mdx Render the parameters for a Selectable Buttons field using Blade syntax, allowing for options like limiting selections or defining the markup. This example limits to one selection and uses an unordered list. ```php {!! $entry->buttons_field->parameters([limit: 1, markup: 'ul']) !!} ``` -------------------------------- ### Structure Nav Tag Usage Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/templates/tags/structure-nav.mdx The `exp:structure:nav` tag is a powerful tool for generating website navigation. It offers numerous parameters to control the output, such as starting point, depth, status, and inclusion/exclusion of specific entries. The examples below demonstrate its usage in Native PHP, Twig, Blade, and GraphQL. ```APIDOC ## Structure Nav Tag This tag generates navigation menus based on your site's structure. It supports various parameters to customize the output. ### Parameters - **start_from** (string) - Optional - Full URI used to indicate where to begin revealing children. - **strict_start_from** (string) - Optional - If set to 'yes', the tag will not return a nav if there is no match to the `start_from` parameter. Otherwise, it returns the full nav from the base of the website. - **show_depth** (integer) - Optional - Reveals a specified number of levels deep for all children pages of the current `start_from` parameter. - **max_depth** (integer) - Optional - Only show up to a specified number of levels deep from the current `start_from` parameter. - **status** (string) - Optional - Restrict pages by status. When prefixed with 'not', all entries except those are available (e.g., 'not closed'). - **include** (string) - Optional - Selectively show specific pages from the same level, separated by pipes (e.g., '1|3|5'). - **exclude** (string) - Optional - Used to hide any single or multiple user-defined entry IDs using the pipe character. All children under a specified ID will be hidden as well (e.g., '2|4|6'). - **show_expired** (string) - Optional - Allows you to show or not show expired entries within the navigation tree ('yes' or 'no'). - **show_future_entries** (string) - Optional - Allows you to show or not show future entries within the navigation tree ('yes' or 'no'). - **override_hidden_state** (string) - Optional - Show all pages regardless of whether they're set to be hidden from the nav ('yes' or 'no'). - **site_url** (string) - Optional - Include the absolute site URL in your nav links instead of relative links ('yes' or 'no'). ### Example Usage (Native PHP) ```php {exp:structure:nav start_from="/some-url" strict_start_from="yes" show_depth=3 max_depth=4 status="closed" include="1|3|5" exclude="2|4|6" show_expired="yes" show_future_entries="yes" override_hidden_state="yes" site_url="yes" } ``` ### Example Usage (Twig) ```twig {% for item in exp.structure.nav({ start_from: "/some-url", strict_start_from: "yes", show_depth: 3, max_depth: 4, status: "closed", include: "1|3|5", exclude: "2|4|6", show_expired: "yes", show_future_entries: "yes", override_hidden_state: "yes", site_url: "yes" }) %} {{ item.children }} {{ item.depth }} {{ item.entry }} {{ item.hidden }} {{ item.slug }} {{ item.url }} {{ item.uri }} {{ item.active }} {{ item.structure_url_title }} {% endfor %} ``` ### Example Usage (Blade) ```php @foreach($exp->structure->nav([ "start_from" => "/some-url", "strict_start_from" => "yes", "show_depth" => 3, "max_depth" => 4, "status" => "closed", "include" => "1|3|5", "exclude" => "2|4|6", "show_expired" => "yes", "show_future_entries" => "yes", "override_hidden_state" => "yes", "site_url" => "yes" ]) as $item) {{ $item['children'] }} {{ $item['depth'] }} {{ $item['entry'] }} {{ $item['hidden'] }} {{ $item['slug'] }} {{ $item['url'] }} {{ $item['uri'] }} {{ $item['active'] }} {{ $item['structure_url_title'] }} @endforeach ``` ### Example Usage (GraphQL) ```graphql { exp_structure_nav( start_from: "/some-url", strict_start_from: "yes", show_depth: 3, max_depth: 4, status: "closed", include: "1|3|5", exclude: "2|4|6", show_expired: "yes", show_future_entries: "yes", override_hidden_state: "yes", site_url: "yes" ) { children { ... } depth entry { title } hidden slug url uri active structure_url_title } } ``` ``` -------------------------------- ### Query with Length and Limit Modifiers Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/graphql/queries/channel-entries.md Shows how to apply the 'length' modifier to get the character count of a field and chain 'limit' with 'length' to get the length of a truncated string. Coilpack maintains modifier order despite GraphQL's unordered arguments. ```graphql { exp_channel_entries { entry_id title page_content(length:true) excerpt_length:page_content( limit: {characters: 10, end_char: "..."}, length: true ) } } ``` -------------------------------- ### Retrieve Active ExpressionEngine Member Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/advanced/authentication.md Use this to get the currently authenticated ExpressionEngine member as an Eloquent model. ```php auth('coilpack')->user() ``` -------------------------------- ### Create Gatsby Site Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/guides/using-graphql-gatsby.md Use npm to create a new Gatsby site. This command initializes a new project with the specified name. ```bash npm init gatsby my-coilpack-site -- -y ``` -------------------------------- ### Register GraphQL Classes in addon.setup.php Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/advanced/addons/graphql.md Register your custom GraphQL types and queries within the `coilpack` section of your add-on's `addon.setup.php` file. This makes them available for use in your GraphQL schema. ```php return array( 'name' => 'Addon Name' 'description' => 'Addon Description' ... 'coilpack' => [ 'tags' => [...], 'fieldtypes' => [..], 'graphql' => { 'types' => [ 'MyAddonTagType' => MyAddonNamespace\Types\MyAddonTagType::class ], 'queries' => [ 'query_name' => MyAddonNamespace\Queries\MyAddonQuery::class ] } ] ); ``` -------------------------------- ### Structure Navigation Parameter: include Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/templates/tags/structure-nav.mdx Allows for the selective inclusion of specific pages from the same level as the 'start_from' parameter. Entry IDs are separated by the pipe character. ```php include: "1|3|5" ``` -------------------------------- ### Basic Tag Syntax Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/templates/tags.md Illustrates the fundamental syntax for calling ExpressionEngine tags within Coilpack, including the basic tag structure and how to pass parameters. ```twig {# Tag #} {{ exp.addon_name.tag_name }} ``` ```twig {# Tag with parameters #} {{ exp.addon_name.tag_name({name: "value"}) }} ``` -------------------------------- ### Limit Checkboxes Output (Blade) Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/templates/fieldtypes/checkboxes.mdx Limit the number of displayed checkbox options using the `limit` parameter. This example limits to 1 option. ```php {{ $entry->checkboxes_field->parameters(['limit' => 1]) }} ``` -------------------------------- ### Build Static Content with Yarn Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/README.md Generates static site content for deployment. The output is placed in the 'build' directory. ```bash yarn build ``` -------------------------------- ### Limit Checkboxes Output (Twig) Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/templates/fieldtypes/checkboxes.mdx Limit the number of displayed checkbox options using the `limit` parameter. This example limits to 1 option. ```twig {{ entry.checkboxes_field.parameters({limit: 1}) }} ``` -------------------------------- ### Set Checkboxes Markup (Blade) Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/templates/fieldtypes/checkboxes.mdx Control the output markup for checkboxes using the `markup` parameter. This example sets the markup to an unordered list (`ul`). ```php {{ $entry->checkboxes_field->parameters(['markup' => 'ul']) }} ``` -------------------------------- ### Create New Laravel Project Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/getting-started.md Use this command to create a new Laravel project. It's recommended to use the latest supported version. ```sh composer create-project --prefer-dist "laravel/laravel:<=11" project-name cd project-name composer require expressionengine/coilpack:2.x php artisan coilpack ``` ```sh composer create-project --prefer-dist laravel/laravel project-name ``` ```sh composer create-project --prefer-dist laravel/laravel:^9.0 project-name ``` -------------------------------- ### Set Checkboxes Markup (Twig) Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/templates/fieldtypes/checkboxes.mdx Control the output markup for checkboxes using the `markup` parameter. This example sets the markup to an unordered list (`ul`). ```twig {{ entry.checkboxes_field.parameters({markup: 'ul'}) }} ``` -------------------------------- ### Create a Custom Template Tag Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/advanced/addons/tags.md Implement a custom template tag by extending the `Expressionengine\Coilpack\View\Tag` class and defining a `run()` method. ```php 'Addon Name' 'description' => 'Addon Description' ... 'coilpack' => [ 'fieldtypes' => [ 'super_checkbox' => 'Addon\Fieldtypes\SuperCheckbox' ] ] ); ``` -------------------------------- ### Channel Categories Tag with All Parameters (Native) Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/templates/tags/channel-categories.mdx Demonstrates the usage of various parameters with the native ExpressionEngine tag for filtering and controlling category output. ```php {exp:channel:categories category_id="2|45|4|9" category="cars|sports" channel="channel1|channel2" group_id="4" limit=1 site="1" } {category_name} {/exp:channel:categories} ``` -------------------------------- ### Format Duration Output Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/templates/fieldtypes/duration.mdx Customize how the duration is displayed using the `format` parameter. This example shows hours and minutes. Replace `duration_field` with your actual field name. ```twig {{ entry.duration_field.parameters({format: '%h hrs, %m min'}) }} ``` ```php {{ $entry->duration_field->parameters(['format' => '%h hrs, %m min']) }} ``` -------------------------------- ### Display Channel Entries with Pagination (Native) Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/templates/tags/channel-entries.mdx Use the `paginate` parameter to enable top pagination for channel entries in native templating. ```php {exp:channel:entries paginate="top"} {title} {/exp:channel:entries} ``` -------------------------------- ### Including Templates: Twig vs. Blade Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/templates/index.mdx Shows how to extend layout files or include partials in Twig and Blade, using the 'ee::' namespace for ExpressionEngine templates. ```twig {% extends 'ee::folder._layout' %} {% include 'ee::folder._partial' %} ``` ```php @extends('ee::folder._layout') @include('ee::folder._partial') ``` -------------------------------- ### Get RTE Excerpt Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/templates/fieldtypes/rich-text-editor.mdx Retrieves the content of an RTE field up to the 'Read More' separator. If no separator exists, it returns the full content. This is useful for generating summaries or previews. ```twig {{ entry.rte_field.excerpt }} ``` ```php {{ $entry->rte_field->excerpt }} ``` -------------------------------- ### Structure Navigation Parameter: strict_start_from Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/templates/tags/structure-nav.mdx Ensures that a navigation menu is only returned if a match is found for the 'start_from' parameter. If no match exists, Structure will not return any navigation, unlike its default behavior of returning the full site nav. ```php strict_start_from: "yes" ``` -------------------------------- ### Listen for ExpressionEngine Hooks as Laravel Events Source: https://context7.com/expressionengine/coilpack-docs/llms.txt Listen for ExpressionEngine extension hooks in Laravel by prefixing the hook name with `ee:`. The `ee:coilpack_booted` event fires after Coilpack initialization. ```php // In a Laravel ServiceProvider's boot() method or routes/web.php use Illuminate\Support\Facades\Event; // Listen for the native EE core_boot hook Event::listen('ee:core_boot', function () { \Log::info('ExpressionEngine core has booted.'); }); // Listen for the Coilpack-specific booted event Event::listen('ee:coilpack_booted', function () { // Safe to interact with EE services from this point \Log::info('Coilpack has fully booted.'); }); // Listen for any EE extension hook using the ee: prefix Event::listen('ee:channel_entries_query', function ($query) { // Modify or inspect the channel entries query }); ``` -------------------------------- ### Write ExpressionEngine Templates with Twig Source: https://context7.com/expressionengine/coilpack-docs/llms.txt Create Twig template files with a `.twig` suffix in `ee/system/user/templates/`. The `exp` global object provides access to EE tags, and `global` exposes EE variables. Use the `ee::` namespace prefix for referencing templates within the EE `user/templates` folder. ```twig {# ee/system/user/templates/default_site/blog.group/index.html.twig #} {% extends 'ee::_layouts._base' %} {% block content %}

{{ global.site_name }}

{# Loop over channel entries with filtering and pagination #} {% set entries = exp.channel.entries({ channel: 'blog', limit: 10, orderby: 'entry_date', sort: 'desc' }) %} {% for entry in entries %}

{{ entry.title }}

{{ entry.title }} {{ entry.page_content | raw }}
{% else %}

No entries found.

{% endfor %} {# Laravel-powered pagination links #} {{ entries.links }} {# Embed a native EE partial #} {{ exp.embed('_partials/footer', {year: 'now'|date('Y')})} {% endblock %} ``` -------------------------------- ### Channel Entries Tag with All Parameters Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/templates/tags/channel-entries.mdx Illustrates the extensive parameter options available for the Channel Entries tag across different templating engines. Note that not all parameters are intended to be used together. ```php {exp:channel:entries author_id="3" category_id="2|45|4|9" category="cars|sports" channel="channel1|channel2" dynamic="yes" entry_id="not 45|534|807" fixed_order="3|7|1" group_id="4" limit="1" orderby="title" search:body="pickles" site="1" sort="asc" start_on="2023-01-01" stop_before="2023-02-01" url_title="my_wedding|my_honeymoon|my_kids" username="petunia" } {title} {/exp:channel:entries} ``` ```twig {% for entry in exp.channel.entries({ author_id: "3", category_id: "2|45|4|9", category: "cars|sports", channel: "channel1|channel2", dynamic: true, entry_id: "not 45|534|807", fixed_order: "3|7|1", group_id: "4", limit: 1, orderby: "title", search: {body: "pickles"}, site: "1", sort: "asc", start_on: "2023-01-01", stop_before: "2023-02-01", url_title: "my_wedding|my_honeymoon|my_kids", username: "petunia" }) %} {{ entry.title }} {% endfor %} ``` ```php @foreach($exp->channel->entries([ "author_id" => "3", "category_id" => "2|45|4|9", "category" => "cars|sports", "channel" => "channel1|channel2", "dynamic" => true, "entry_id" => "not 45|534|807", "fixed_order" => "3|7|1", "group_id" => "4", "limit" => 1, "orderby" => "title", "search" => ["body" => "pickles"], "site" => "1", "sort" => "asc", "start_on" => "2023-01-01", "stop_before" => "2023-02-01", "url_title" => "my_wedding|my_honeymoon|my_kids", "username" => "petunia" ]) as $entry) {{ $entry->title }} @endforeach ``` ```graphql { exp_channel_entries( author_id: "3", category_id: "2|45|4|9", category: "cars|sports", channel: "channel1|channel2", dynamic: true, entry_id: "not 45|534|807", fixed_order: "3|7|1", group_id: "4", limit: 1, orderby: "title", search: {body: "pickles"}, site: "1", sort: "asc", start_on: "2023-01-01", stop_before: "2023-02-01", url_title: "my_wedding|my_honeymoon|my_kids", username: "petunia" ) { data { title } } } ``` -------------------------------- ### Using Parameters with Select Dropdown Field Source: https://github.com/expressionengine/coilpack-docs/blob/2.x/docs/templates/fieldtypes/select.mdx Modify the output markup for a Select Dropdown field by passing parameters. This example sets the markup to an unordered list (ul). ```twig {{ entry.select_field.parameters({markup: 'ul'}) }} ```