PHP code example of fromholdio / silverstripe-superlinker-ctas
1. Go to this page and download the library: Download fromholdio/silverstripe-superlinker-ctas 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/ */
fromholdio / silverstripe-superlinker-ctas example snippets
use Fromholdio\SuperLinkerCTAs\Model\CTA;
class HomePage extends Page
{
private static $has_one = [
'PrimaryCTA' => CTA::class,
'SecondaryCTA' => CTA::class
];
private static $owns = [
'PrimaryCTA',
'SecondaryCTA'
];
}
use Fromholdio\HasOneEdit\HasOneMiniGridField;
public function getCMSFields(): FieldList
{
$fields = parent::getCMSFields();
$fields->addFieldsToTab('Root.Main', [
HasOneMiniGridField::create('PrimaryCTA', 'Primary CTA', $this),
HasOneMiniGridField::create('SecondaryCTA', 'Secondary CTA', $this)
]);
return $fields;
}
namespace App\Model;
use Fromholdio\SuperLinker\Model\SuperLink;
class CTA extends SuperLink
{
private static $table_name = 'App_CTA';
private static $singular_name = 'Call to Action';
private static $plural_name = 'Calls to Action';
// Add any custom fields or methods here
}