Skip to content

Instantly share code, notes, and snippets.

Avatar

Reece Alexander zanderwar

View GitHub Profile
@zanderwar
zanderwar / DataObjectLinkTracking.php
Last active Jan 31, 2018
Just in case someone else wants to use HTMLText in DataObjects and be able to publish the images that clients can upload into TinyMCE - SilverStripe 4
View DataObjectLinkTracking.php
<?php
namespace Vulcan\Common\Traits;
use SilverStripe\Assets\File;
use SilverStripe\Forms\FieldList;
use SilverStripe\ORM\HasManyList;
/**
* Trait DataObjectLinkTracking
@zanderwar
zanderwar / Page.php
Created Jan 20, 2018
Easier requirements for SilverStripe 4
View Page.php
<?php
use SilverStripe\CMS\Controllers\ContentController;
use SilverStripe\CMS\Model\SiteTree;
/**
* Class Page
*/
class Page extends SiteTree
{
@zanderwar
zanderwar / AbstractApiController.php
Created Oct 15, 2017
Just a simple API output controller for SilverStripe 4
View AbstractApiController.php
<?php
namespace Zanderwar\Api\Controllers;
use SilverStripe\Control\Controller;
use SilverStripe\Control\HTTPResponse;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Convert;
/**
@zanderwar
zanderwar / ModifyModelAdminGridFieldConfig.php
Created Jun 9, 2017
An example of swapping the GridFieldConfig of a particular GridField in a ModelAdmin
View ModifyModelAdminGridFieldConfig.php
<?php
class Example extends ModelAdmin
{
private static $url_segment = 'Example';
private static $menu_title = 'Example';
private static $managed_models = [
Site::class
@zanderwar
zanderwar / PopulateFormDefaults.php
Last active Jun 14, 2017
Populates a SilverStripe Form subclass with DataObject values
View PopulateFormDefaults.php
<?php
class MyForm extends Form
{
/**
* @param Customer $customer
* @return $this
*/
public function setObject(DataObject $object)
{
View ips-thumbnails.html
<img src='http://placehold.it/300x300' class='ipsThumb'/>
<img src='http://placehold.it/300x300' class='ipsThumb ipsThumb_large'/>
<img src='http://placehold.it/300x300' class='ipsThumb ipsThumb_medium'/>
<img src='http://placehold.it/300x300' class='ipsThumb ipsThumb_small'/>
<img src='http://placehold.it/300x300' class='ipsThumb ipsThumb_tiny'/>
View ips-message-alerts.html
<div class='ipsMessage ipsMessage_info'><strong>Information:</strong> Look behind you!</div>
<div class='ipsMessage ipsMessage_error'><strong>Danger:</strong> Seriously..... Look behind you!</div>
<div class='ipsMessage ipsMessage_warning'><strong>Warning:</strong> Is that a robot?!? Be careful it bites!</div>
<div class='ipsMessage ipsMessage_success'><strong>Success:</strong> Wow where did you get that rocket launcher! *BOOM*</div>
<div class='ipsMessage ipsMessage_general'><strong>General:</strong> Yay it has powered down. Thank god no one got hurt!</div>
View ipb4-tags-badges-example.html
<!-- TAGS -->
<span class='ipsTag_prefix'>I am a tag</span>
<div class='ipsTag_prefix'><span>I am another tag</span></div>
<div class='ipsTag_prefix'><span>I am the tag everybody speaks of!</span></div>
<!-- BADGES -->
<span class='ipsBadge ipsBadge_warning ipsBadge_large'>WARNING BADGE</span>
<span class='ipsBadge ipsBadge_positive ipsBadge_large'>POSITIVE BADGE</span>
<span class='ipsBadge ipsBadge_negative ipsBadge_large'>NEGATIVE BADGE</span>
<span class='ipsBadge ipsBadge_neutral ipsBadge_large'>NEUTRAL BADGE</span>
View ipb4-grid-example.html
<div class='ipsGrid'>
<div class='ipsGrid_span4'>span4</div>
<div class='ipsGrid_span3'>span3</div>
<div class='ipsGrid_span5'>span5</div>
</div>
View ipb4-buttons-example.html
<button type='button' class='ipsButton'>Default</button>
<button type='button' class='ipsButton ipsButton_important'>Important</button>
<button type='button' class='ipsButton ipsButton_primary'>Primary</button>
<button type='button' class='ipsButton ipsButton_alternate'>Alternate</button>
<button type='button' class='ipsButton ipsButton_positive'>Positive</button>
<button type='button' class='ipsButton ipsButton_intermediate'>Intermediate</button>
<button type='button' class='ipsButton ipsButton_negative'>Negative</button>
<button type='button' class='ipsButton ipsButton_verylight'>Very Light</button>
<button type='button' class='ipsButton ipsButton_overlaid'>Overlaid</button>
<button type='button' class='ipsButton ipsButton_link'>Link</button>