PHP code example of arillo / silverstripe-arbitrarysettings

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

    

arillo / silverstripe-arbitrarysettings example snippets


use Arillo\ArbitrarySettings\SettingsExtension;

public function getCMSFields()
{
    $fields = parent::getCMSFields();
    if ($settingsField = SettingsExtension::field_for($this))
    {
        $fields->addFieldToTab('Root.Main', $settingsField);
    }
    return $fields;
}

$this->SettingByName('image_alignment') // returns 'left' or 'right'

// will show all settings but show_title
$settingsField->exclude(['show_title']);

// will show show_title setting only
$settingsField->

$settingsField->updateDefaultForKey('show_title', 1);