Skip to content

Instantly share code, notes, and snippets.

View thezenmonkey's full-sized avatar

Richard Rudy thezenmonkey

View GitHub Profile
<?php
$galleryManagerConfig
->removeComponentsByType('GridFieldDataColumns')
->removeComponentsByType('GridFieldSortableHeader')
->removeComponentsByType('GridFieldAddExistingAutocompleter')
->removeComponentsByType('GridFieldPaginator')
->removeComponentsByType('GridFieldPageCount')
->addComponents(
new GridFieldTitleHeader(),
new GridFieldOrderableRows(),
@thezenmonkey
thezenmonkey / encypt decrypt
Created October 14, 2013 17:49
encrypted dataobject for SS
<?php
class Client extends DataObject {
public static $db = array (
"FirstName" => "Text",
"LastName" => "Text",
"Email" => "Text",
"PhoneNumber" => "Varchar(9)",
"YearOfBirth" => "Varchar(4)",
@thezenmonkey
thezenmonkey / Tag Specifc RSS for SilverStrip Blog
Created December 5, 2013 16:21
Quick function to add tag specific RSS feed to SilverStripe Blog. You can add this to DataExtension to BlogTree_Controller
function tag() {
if ($this->owner->request->param('Action') == 'tag' && $this->owner->request->param('OtherID') == "rss") {
$entries = $this->owner->Entries(20, Convert::raw2xml($this->owner->request->latestParam('ID')));
if($entries) {
$rss = new RSSFeed($entries, $this->owner->Link('rss'), ($blogName ? $blogName : $altBlogName), "", "Title", "RSSContent");
return $rss->outputToBrowser();
}
@thezenmonkey
thezenmonkey / CMSBatchActions_TranslateTo.php
Last active June 9, 2016 00:04
Silverstripe CMS Batch Action to Create Translations for Translatable
<?php
class CMSBatchActions_TranslateTo extends CMSBatchAction {
public function getActionTitle() {
return _t('CMSBatchActions.TRANSLATETO', 'Translate to...');
}
public function run(SS_List $pages) {
@thezenmonkey
thezenmonkey / LeftAndMain.TranslateTo.js
Last active June 9, 2016 00:04
Javscript for Batch Translate
/*jslint browser: true, nomen: true, white: true */
/**
* Javascript to process extra batch actions. Currently deals with the TranslateTo action
*/
(function($) {
'use strict';
$.entwine('ss.tree', function($){
@thezenmonkey
thezenmonkey / CMSBatchAction_TransalteToController.php
Last active June 9, 2016 00:05
Controller to Manage Batch Translation
<?php
/**
* Controller to process translate pages batch action.
*
* @package batchactionsplus
*/
class CMSBatchAction_TransalteToController extends LeftAndMain {
private static $url_segment = 'batchtranslateto';
@thezenmonkey
thezenmonkey / TranslatableBlockPage.php
Last active September 6, 2016 14:10
Extension to use for the Basis of integrating SilverStripe Block with Translatable. Add this extension to your page type or copy the onTranslatableCreate function to your page class.
<?php
class TranslatableBlockPage extends DataExtension {
/**
* Simple support for Translatable, when a page is translated, copy all content blocks and relate to translated page
* Apply to Pages
*/
public function onTranslatableCreate() {
@thezenmonkey
thezenmonkey / AutosortBlocks.php
Created November 19, 2016 23:09
onAfterWrite function to auto incriment blocks
public function onAfterWrite()
{
parent::onAfterWrite();
if ($this->hasExtension('FilesystemPublisher')) {
$this->republish($this);
}
$currentPage = Controller::curr()->getRequest()->requestVar('CMSMainCurrentPageID');
// Check if Block is Used on Current Page and has a Sort of 0
$query = new SQLSelect();
@thezenmonkey
thezenmonkey / SectionElement.php
Created April 19, 2018 21:42
Extending Element List
<?php
use DNADesign\ElementalList\Model\ElementList;
class SectionElement extends ElementList
{
private static $db = [
'FullWidth' => 'Boolean'
];
private static $controller_template = 'NoElementHolder';
@thezenmonkey
thezenmonkey / PublishAllFiles.php
Last active May 18, 2018 18:34 — forked from a2nt/PublishAllFiles.php
SS3 > SS4.1 protected folder migration script
<?php
/*
* Generates FileHash and moves files to .protected folder
* Re-generates CMS thumbs on the second run and publish files
*/
use SilverStripe\Dev\BuildTask;
use SilverStripe\Control\Director;
use SilverStripe\Assets\File;