PHP code example of tfd / statamic-content-modules

1. Go to this page and download the library: Download tfd/statamic-content-modules 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/ */

    

tfd / statamic-content-modules example snippets



// app/ViewModels/Page.php

namespace App\ViewModels;

use TFD\ContentModules\ViewModels\General;

class Page extends General
{
}


// app/ViewModels/News.php

use TFD\ContentModules\ViewModels\General;

class Page extends General
{
    protected $field_handle = 'my_custom_handle';
}


// app/ContentModules/Gallery.php

namespace App\ContentModules;

use TFD\ContentModules\ContentModules\ContentModule;

class Gallery extends ContentModule
{
    public function data(): array
    {
        $data = $this->data;

        $data['foo'] = 'bar';

        return $data;
    }
}