PHP code example of slonline / silverstripe-calltoaction

1. Go to this page and download the library: Download slonline/silverstripe-calltoaction 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/ */

    

slonline / silverstripe-calltoaction example snippets

t
class MyCallToAction extends ViewableData implements ShortcodeableInterface
{
    private static $singular_name = 'My Call To Action';
    private static $shortcode = 'mycta';
    
    public static function parse_shortcode($attributes, $content, $parser, $shortcode): string
    {
        return self::create()->renderWith(self::class);
    }
    
    public function getCallToActionPlaceHolder($attributes): string
    {
        return self::create()->renderWith(self::class);
    }
    
    public function singular_name()
    {
        $name = $this->config()->get('singular_name');
        if ($name) {
            return $name;
        }
        return ucwords(trim(strtolower(preg_replace(
            '/_?([A-Z])/',
            ' $1',
            ClassInfo::shortName($this)
        ))));
    }
    
    /**
     * Custom fields for Call To Action form
     *
     * @return FieldList
     */
    public function getShortcodeFields()
    {
        $fields = FieldList::create();
        ...
        return $fields;
    }
}