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
@sunnysideup
sunnysideup / SendPdfViaEmail.php
Last active May 29, 2023 01:10
Sending a PDF Via Email in Silverstripe
<?php
namespace Sunnysideup\Web\Tasks;
use DirectoryIterator;
use SilverStripe\Control\Director;
use SilverStripe\Control\Email\Email;
use SilverStripe\Dev\BuildTask;
class SendPdfViaEmail extends BuildTask
@sunnysideup
sunnysideup / LogRunnerCache.php
Last active October 26, 2022 01:25
Log Runnner - running only a few at the time for Silverstripe
<?php
namespace MyAmazingWebsite\App\Model\Logs;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\DataObject;
use SilverStripe\Core\Flushable;
// prepare the array by adding level, ID and parent to each item of the array
function prepare (array) {
let level, t
for (let i = 0, n = array.length; i < n; i++) {
t = array[i]
t.el = t
level = parseInt(t.tagName[1], 10)
t.level = level
t.idt = i + 1
# RESULTS /src/Control:
```txt
------ ----------------------------------------------------------------------------------------------------------------------
Line Controller.php
------ ----------------------------------------------------------------------------------------------------------------------
128 Negated boolean expression is always true.
201 Negated boolean expression is always false.
<?php
namespace My\Own\Private\Idaho;
use SilverStripe\Control\Controller;
use SilverStripe\Core\Injector\Injectable;
use SilverStripe\ORM\DataObject;
use SilverStripe\View\ArrayData;
use SilverStripe\View\SSViewer;
#!/bin/bash
# source: https://askubuntu.com/questions/1075157/unable-to-set-my-screen-resolution-higher
xrandr
cvt 1920 1080
sudo xrandr --newmode "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
sudo xrandr --addmode VGA-1 "1920x1080_60.00"
@sunnysideup
sunnysideup / test-0-package.json
Last active November 25, 2018 21:03
webpack examples
{
"name": "ss-webpack",
"version": "2.11.2",
"description": "A silverstripe theme setup using webpack to bundle assets and provide a front end build system. ",
"main": "index.js",
"scripts": {
"watch": "NODE_ENV=development webpack-dashboard -- webpack-dev-server",
"dev": "NODE_ENV=development webpack --progress",
"build": "NODE_ENV=production webpack --progress"
},
@sunnysideup
sunnysideup / GridFieldConfig_RecordEditor_Fix.php
Last active October 12, 2018 20:10
Fixing ModelAdmin in CWP 2.1
<?php
use SilverStripe\Core\Extension;
use SilverStripe\Forms\GridField\GridField_ActionMenu;
use SilverStripe\Forms\GridField\GridFieldDeleteAction;
class GridFieldConfig_RecordEditor_Fix extends Extension
{
function updateConfig()
@sunnysideup
sunnysideup / Page.php
Created September 26, 2018 00:54
move fields in sitlverstripe
<?php
class Page {
function getCMSFields()
{
$fields = parent::getCMSFields();
$publishingDetails = ToggleCompositeField::create(
'PublishingHolderToggle',
'Publishing',
$fields->fieldByName('Root.PublishingSchedule')
@sunnysideup
sunnysideup / MyExampleDeleteAllForPage.php
Last active January 30, 2018 22:38
Delete a Silverstripe Page for both STAGE and LIVE
<?php
class MyExampleDeleteAllForPage extends Object
{
private static function delete_page($idOrPage)
{
if($idOrPage instanceof SiteTree) {
$id = $idOrStage->ID;