Skip to content

Instantly share code, notes, and snippets.

Avatar

Hiren Patel ninty9notout

View GitHub Profile
@ninty9notout
ninty9notout / Housekeeping.php
Created May 5, 2020
SilverStripe 2 Versioned Records Housekeeping
View Housekeeping.php
<?php
ini_set('memory_limit', '256M');
ini_set('max_execution_time', '600');
class Housekeeping extends BuildTask
{
/**
* @var string
*/
@ninty9notout
ninty9notout / CMSMainExtension.php
Last active Apr 4, 2019
Remove the preview field from SilverStripe
View CMSMainExtension.php
<?php
use SilverStripe\Core\Extension;
use SilverStripe\Forms\Form;
class CMSMainExtension extends Extension
{
/**
* Removes the CMS preview by removing the literal field which
* renders the page. This needs to be attached to `CMSMain`:
@ninty9notout
ninty9notout / Page.php
Created Apr 3, 2019
SilverStripe subsite tree drop down
View Page.php
<?php
$subsites = DataObject::get(Subsite::class)->map('ID', 'Title');
$fields->insertBefore('internal_linkID',
DropdownField::create('internal_linkID_SubsiteID', 'Subsite')
->setSource($subsites->map('ID', 'Title'))
->addExtraClass('subsitestreedropdownfield-chooser no-change-track')
);
$internalLinkField = SubsitesTreeDropdownField::create(
@ninty9notout
ninty9notout / detect.js
Last active Feb 8, 2018
Detect browser and add class to <html> tag
View detect.js
// Credit to https://stackoverflow.com/a/9851769
(function () {
// Opera 8.0+
var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
// Firefox 1.0+
var isFirefox = typeof InstallTrigger !== 'undefined';
// Safari 3.0+ "[object HTMLElementConstructor]"
var isSafari = (!!navigator.userAgent.match(/iPad/i) || !!navigator.userAgent.match(/iPhone/i) && !!navigator.userAgent.match(/WebKit/i) && !navigator.userAgent.match(/CriOS/i)) || /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || (typeof safari !== 'undefined' && safari.pushNotification));
// Internet Explorer 6-11
View dabblet.css
/**
* Hangar 18 Website
*/
/* html5doctor.com Reset v1.6.1 (http://html5doctor.com/html-5-reset-stylesheet/) - http://cssreset.com */
html,body,div,span,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,abbr,address,cite,code,del,dfn,em,img,ins,kbd,q,samp,small,strong,sub,sup,var,b,i,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,figcaption,figure,footer,header,hgroup,menu,nav,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent}
body{line-height:1}
article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}
nav ul{list-style:none}
blockquote,q{quotes:none}
blockquote:before,blockquote:after,q:before,q:after{content:none}
You can’t perform that action at this time.