PHP code example of restruct / silverstripe-simpler
1. Go to this page and download the library: Download restruct/silverstripe-simpler 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/ */
restruct / silverstripe-simpler example snippets
use SilverStripe\View\Requirements;
Requirements::javascript('mymodule/client/dist/js/my-vue-app.js', ['type' => 'module']);
use Restruct\Silverstripe\Simpler\AdminExtension;
AdminExtension::
use Restruct\Silverstripe\Simpler\SimplerModalField;
use Restruct\Silverstripe\Simpler\SimplerModalAction;
// Iframe content (e.g., preview) with extra large modal
SimplerModalField::create('preview', 'Preview')
->setIframeSrc('/admin/preview/123')
->setIframeHeight('80vh')
->setModalSize('xl') // 'sm', 'lg', 'xl' or custom like '800px', '90vw'
->setCloseBtn(false) // Hide footer close button (default: true)
->setButtonIcon('eye')
->addExtraClass('btn-outline-info');
// HTML content with custom width
SimplerModalField::create('info', 'Info')
->setContent('<p>Some information here</p>')
->setModalSize('600px');
// Custom dialog title (different from button text)
SimplerModalField::create('details', 'Show Details')
->setDialogTitle('Item Details')
->setContent($myHtmlContent);
// CMS action with form fields (form submits directly - no iframe!)
SimplerModalAction::create('translate', 'Translate')
->setFieldList(FieldList::create([
DropdownField::create('lang', 'Language', ['en' => 'English', 'nl' => 'Dutch']),
TextareaField::create('notes', 'Notes'),
]))
->setDialogButtonTitle('Start Translation');
// Change from:
use LeKoala\PureModal\PureModal;
use LeKoala\PureModal\PureModalAction;
// To:
use Restruct\Silverstripe\Simpler\SimplerModalField as PureModal;
use Restruct\Silverstripe\Simpler\SimplerModalAction as PureModalAction;