Skip to content

Instantly share code, notes, and snippets.

View wsydney76's full-sized avatar

Werner wsydney76

  • Munich, Germany
View GitHub Profile
@wsydney76
wsydney76 / ACTIONS.md
Last active March 18, 2025 13:23
ACTIONS: Library functions for calling Craft CMS controllers from JavaScript

How to Use the Craft CMS Actions Twig Component

This documentation explains how to use the @extras/_actions.twig component in Craft CMS to call web controller actions via JavaScript and display success or error notices.


Component Overview

The Actions component allows you to make asynchronous requests to Craft CMS web controller actions and handle responses within your JavaScript code. Additionally, the component can display success or error notifications to users based on the outcome of the requests.

@wsydney76
wsydney76 / VideoService.php
Created January 15, 2025 10:32
Create an image from video asset, that can be used for <video poster="..."> or for index pages.
<?php
namespace modules\art\services;
use Craft;
use craft\base\Component;
use craft\elements\Asset;
use craft\fs\Local;
use craft\helpers\Console;
use Exception;
@wsydney76
wsydney76 / ContentController.php
Created October 25, 2024 15:12
Instant Craft CMS instant search
<?php
namespace modules\main\controllers;
use craft\elements\Entry;
use craft\web\Controller;
use yii\web\Response;
/**
* Content controller
@wsydney76
wsydney76 / MigrationController.php
Created March 19, 2024 18:17
Get fields in Craft CMS 5 with identical settings
<?php
// ....
public function actionConsolidateFieldsCandidates()
{
$signatures = [];
foreach (Craft::$app->getFields()->getAllFields() as $field) {
$signature = [
@wsydney76
wsydney76 / MigrationController.php
Last active April 24, 2024 05:04
Craft CMS CLI command that helps to detect errors after migration to Craft 5 (renamed entry types etc.)
<?php
namespace modules\main\console\controllers;
use Craft;
use craft\console\Controller;
use craft\elements\Entry;
use craft\helpers\Console;
use GuzzleHttp\Exception\GuzzleException;
use yii\console\ExitCode;
@wsydney76
wsydney76 / CollapseSidebarAsset.php
Last active February 29, 2024 19:28
Make sections of Craft 5 element indexes collapsible
<?php
namespace modules\main\web\assets\collapsesidebar;
use craft\web\AssetBundle;
/**
* Collapse Sidebar asset bundle
* Experimental!
*