Skip to content

Instantly share code, notes, and snippets.

View bueckl's full-sized avatar

Jochen Gülden bueckl

View GitHub Profile
@bueckl
bueckl / HTMLGridfield.php
Created August 17, 2015 16:06
HTML in Gridfield
function getColourNice(){
$obj= HTMLText::create();
$obj->setValue('<div style="background-color: '.$this->Colour.'; width: 100px; height: 100px;">&nbsp;</div>');
return $obj;
}
@bueckl
bueckl / Multi Column Nav Example #SS3, #Silverstripe 3
Last active August 29, 2015 14:25
Multi Column Nav Example #SS3, #Silverstripe 3
/* On Controller …
This method splits the nav in rows of 3
*/
public function getCustomMenu($level = 1) {
@bueckl
bueckl / wget
Last active October 11, 2023 08:05
Wget examples
#Spider Websites with Wget – 20 Practical Examples
Wget is extremely powerful, but like with most other command line programs, the plethora of options it supports can be intimidating to new users. Thus what we have here are a collection of wget commands that you can use to accomplish common tasks from downloading single files to mirroring entire websites. It will help if you can read through the wget manual but for the busy souls, these commands are ready to execute.
1. Download a single file from the Internet
wget http://example.com/file.iso
2. Download a file but save it locally under a different name
wget ‐‐output-document=filename.html example.com
@bueckl
bueckl / gist:c56f5380e81c9fa7d56e
Created June 24, 2015 13:53
Hide Browser URL Bar
<!-- Make it fullscreen / hide the browser URL bar -->
<meta name="apple-mobile-web-app-capable" content="yes" />
@bueckl
bueckl / gist:db41a070dc2404403688
Created June 23, 2015 21:52
#SS3 adding original Content below formfields on Translated DOs
$ContentFutter1 = new HTMLEditorField('ContentFutter1', 'Spalte 1');
$ContentFutter2 = new HTMLEditorField('ContentFutter2', 'Spalte 2');
$ContentFutter3 = new HTMLEditorField('ContentFutter3', 'Spalte 3');
// transform the fields if we're not in the default locale
if(Translatable::default_locale() != Translatable::get_current_locale()) {
$translation = $this->getTranslation(Translatable::default_locale());
$transformation = new Translatable_Transformation($translation);
$ContentFutter1 = $transformation->transformFormField($ContentFutter1);
$ContentFutter2 = $transformation->transformFormField($ContentFutter2);
@bueckl
bueckl / gist:5b6e5a3d8c9cfdd2ac9f
Created May 27, 2015 18:40
SS3, Silverstripe, GridField config Field #Casting #Formating
$gridField->getConfig()->getComponentByType('GridFieldDataColumns')->setDisplayFields(array(
'Created' => 'Erstellt',
'Code' => 'Code',
'Value' => 'Wert',
'Origin' => 'Gutscheinart',
'Invoice.Buyer.FirstName' => 'Vorname',
'Invoice.Buyer.Surname' => 'Nachname',
'inUse' => 'Benutzt'
));
@bueckl
bueckl / isEmptyObject
Created May 25, 2015 18:48
Silverstripe SS3 isEmptyObject
function isEmptyObject($o) {
if ( $o->toMap()['ID'] > 0) {
return false;
} else {
return true;
}
}
@bueckl
bueckl / TabOrder
Created May 20, 2015 08:57
Silverstripe SS3 moving arounf Tabs / TabOrder
public function getCMSFields() {
$fields = parent::getCMSFields();
$TabSet = $fields->findOrMakeTab('Root');
$Main = $TabSet->fieldByName('Main');
$TabSet->removeByName('Main');
………………
@bueckl
bueckl / gist:5fe6e23be7ba48285a48
Last active August 29, 2015 14:20
Download Files in Folder as ZIP #SS3 #SilverStripe
/**
* @return SS_HTTPRequest
*/
public function assetbackup() {
$name = $this->Title . '.zip';
$tmpName = TEMP_FOLDER . '/' . $name;
$zip = new ZipArchive();
if(!$zip->open($tmpName, ZipArchive::OVERWRITE)) {
user_error('Client Export Extension: Unable to read/write temporary zip archive', E_USER_ERROR);
return;
@bueckl
bueckl / Currency
Created April 10, 2015 08:32
Currency EUR quick and dirt #SS3
<?php
class CurrencyEuro extends Currency {
protected static $currencySymbol = '€';
public function Nice() {
$val = number_format(abs($this->value), 2, ',', '.') . '&nbsp;' . self::$currencySymbol;
if($this->value < 0) return "($val)";
else return $val;