PHP code example of johnfmorton / craft-twig-scaffold

1. Go to this page and download the library: Download johnfmorton/craft-twig-scaffold library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

johnfmorton / craft-twig-scaffold example snippets



// config/twig-scaffold.php

return [
    // A field type from a plugin that doesn't describe itself yet.
    acme\podcast\fields\PodcastAudioField::class => [
        'twig' => '<audio controls src="{{ $value.url }}"></audio>',
        'guard' => '$value',
    ],

    // Override one of Craft's own field types, here to use your picture macro.
    craft\fields\Assets::class => [
        "{% import '_macros/media' as media %}",
        '{% for asset in $value.all() %}',
        '    {{ media.picture(asset) }}',
        '{% endfor %}',
    ],
];


// src/twig-scaffold.php in your plugin

use acme\podcast\fields\PodcastAudioField;

return [
    PodcastAudioField::class => '<audio controls src="{{ $value.url }}"></audio>',
];