Skip to content

Instantly share code, notes, and snippets.

View muskie9's full-sized avatar

Nic muskie9

View GitHub Profile
<?php
/**
*
* @package FoxyStripe
*
*/
class ProductCategory extends DataObject {
private static $db = array(
<?php
require_once( dirname(dirname(__FILE__)).'/thirdparty/simple_html_dom.php' );
// Transforms the content area of the page
// Usage:
// $Content.Parse(ContentParser)
class ContentParser extends TextParser {
<?php
class MyCustomProduct extends ProductPage{
/* ... */
public function ProductOptionsForm() {
$form = $this->StartForm();
$form .= $this->AddBaseProductDetails();
$form .= $this>ProductOptionsSet();
<?php
class OrderDetailDataExtension extends DataExtension {
private static $db = array(
'MyCustomField' => 'Varchar(50)'
);
public function onAfterWrite(){
parent::onBeforeWrite();
@muskie9
muskie9 / Old to New site 301 htaccess
Created February 4, 2015 20:44
This will take any page (i.e. http://olddomain.com/some-url-segment) and redirect it to a new domain (i.e. http://www.newdomain/some-url-segment)
RewriteCond %{HTTP_HOST} !newdomain.com$ [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]
@muskie9
muskie9 / TabOrderControl.php
Last active August 29, 2015 14:14
A way to create a tab and insert it after the last tab
public function getCMSFields(){
$fields = parent::getCMSFields();
$rootTab = $fields->fieldByName('Root');
$this->extend('updateCMSFields', $fields);
$tabs = $rootTab->getTabSet();
$last = $tabs->last()->name;
$rootTab->insertAfter(Tab::create('FoolashTab'), $last);
public function getCMSFields() {
$fields = FieldList::create(
$tabSet = new TabSet('Root',
$mainTab = new Tab('Main',
new TextField('FieldOne'),
new TextField('FieldTwo')
)
)
);
//Remove fields so we can customise them
$dbFields = $this->stat('db');
foreach($dbFields as $dbFieldKey => $val){
$fields->removeByName($dbFieldKey);
}
<?php
class SampleDO extends DataObject {
public function canCreate($memeber = null){
return true;
}
public function canEdit($memeber = null){
return true;
<?php
public function onBeforeWrite(){
parent::onBeforeWrite();
$siteConfig = SiteConfig::current_site_config();
if(!$siteConfig->StoreKey){
$key = FoxyCart::setStoreKey();
+ while(!ctype_alnum($key)){
+ $key = FoxyCart::setStoreKey();