Skip to content

Instantly share code, notes, and snippets.

View sunnysideup's full-sized avatar
💭
developing Silverstripe Applications

Sunny Side Up sunnysideup

💭
developing Silverstripe Applications
View GitHub Profile
#!/bin/bash
# how to install?
# 1. create ~/local/bin/git-meld-all and copy contents below
# 2. edit ~/.bashrc to include this line ... export PATH=$PATH:~/local/bin/
# 3. make sure the git-meld-all file can be executed
# deleting foo.bar.orig files ...
find . -name "*.orig" -exec rm "{}" -i \;
@sunnysideup
sunnysideup / Page.php
Created September 27, 2016 01:15
page.ss
<?php
class Page extends SiteTree {
private static $has_many = array(
'Emails' => 'Page_Email'
);
/**
* CMS Fields
@sunnysideup
sunnysideup / ExampleBuildTask.php
Last active September 21, 2016 23:58
Making Silverstripe Modules fit for purpose
<?php
class ExampleBuildTask extends BuildTask
{
protected $title = 'Add more data to our example';
protected $description = 'Takes the Example Objects and populates the example fields';
protected $enabled = true;
@sunnysideup
sunnysideup / getAllStatics.php
Created July 19, 2016 23:49
retrieve all statics from a silverstripe module / project ....
<?php
/**
* PSEUDO CODE!
*
*/
$returnArray = array();
foreach($allClasses as $class) {
@sunnysideup
sunnysideup / MyJSFx.js
Last active May 29, 2016 04:54
How to apply PHP variables into a JS module. Old and New Way ...
/**
*
* @param String RootSelector - e.g. MyForm as in <form id="MyForm"> or <div id="MyDiv">
*
*/
var MyJSFx = function(RootSelector) {
<?php
/**
* replaces `Requirements_Backend`
* this class blocks all JS and CSS files and intead copies them to a folder
* for webpack inclusion.
*
* `Custom` (inline) CSS / JS still works as normal.
*
*/
@sunnysideup
sunnysideup / SiteTreeExamples.php
Last active April 7, 2016 07:39
typical stuff in a Page
<?php
class MyPage extends Page {
/**
* can the page be created at the root
* of the site tree (i.e. without parent)?
* @var boolean
*/
private static $can_be_root = true;
<?php
class MyPage extends Page {
private static $many_many = array(
"CoolPages" => "SiteTree"
);
function getCMSFields(){
$fields->addFieldToTab(
@sunnysideup
sunnysideup / MyObject.php
Last active February 25, 2016 22:43
find or create
<?php
class MyObject extends DataObject {
/**
* finds or creates a MyObject based the value for MyObject.SomethingElse
*
* @param string $code
* @return MyObject
*/
@sunnysideup
sunnysideup / ReplacementDataExample.php
Created October 12, 2015 00:26
ReplacementDataExample.php
<?php
class ReplacementData {
//...
private function getData($to) {
//...
$array = array();