Skip to content

Instantly share code, notes, and snippets.

View thezenmonkey's full-sized avatar

Richard Rudy thezenmonkey

View GitHub Profile
@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();
}
<?php
$galleryManagerConfig
->removeComponentsByType('GridFieldDataColumns')
->removeComponentsByType('GridFieldSortableHeader')
->removeComponentsByType('GridFieldAddExistingAutocompleter')
->removeComponentsByType('GridFieldPaginator')
->removeComponentsByType('GridFieldPageCount')
->addComponents(
new GridFieldTitleHeader(),
new GridFieldOrderableRows(),
@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 / 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 / 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 / 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 / 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 / vc_vonts.php
Created April 3, 2018 18:39
Visual Composer Overide Google Font List
add_filter('vc_google_fonts_get_fonts_filter','custom_fonts');
// $font_list from js_composer/include/params/google_fonts/google_fonts.php
function custom_fonts( $fonts_list ) {
$fonts_list = array();
$open_sans = new stdClass();
$open_sans->font_family = 'Open Sans';
$open_sans->font_styles = '300,300italic,regular,italic,600,600italic,700,700italic,800,800italic';
@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';