Skip to content

Instantly share code, notes, and snippets.

View ryanwachtl's full-sized avatar

Ryan Wachtl ryanwachtl

View GitHub Profile
@ryanwachtl
ryanwachtl / (MiniCartItemShortcodeHandler) MiniCart.php
Created October 17, 2011 17:19
SilverStripe PayPal Mini Cart Integration
<?php
class MiniCart extends DataObjectDecorator {
...
public static function MiniCartItemShortcodeHandler($attributes, $content = null, $parser = null) {
if(empty($attributes['name']) || empty($attributes['price'])) {
return;
@ryanwachtl
ryanwachtl / getURLParameter.js
Created March 16, 2012 21:28 — forked from Jorgelig/getURLParameter.js
getURLParameter
//parameter or returns an empty string
jQuery.getURLParameter = function(name) {
return decodeURI(
(RegExp(name + '=' + '(.+?)(&|$)').exec(location.search) || [, ''])[1]
);
};
@ryanwachtl
ryanwachtl / composer.json
Last active December 14, 2015 06:49
Boilerplate for a SilverStripe theme or module composer.json file.
{
"name": "{{ YOUR NAMESPACE }}/{{ PACKAGE NAME }}",
"type": "{{ silverstripe-module}} || {{ silverstripe-theme}}",
"description": "SilverStripe",
"keywords": ["silverstripe", "keyword"],
"license": "BSD-3-Clause",
"authors": [{
"name": "{{ AUTHOR NAME }}",
"homepage": "{{ AUTHOR WEBSITE }}"
}],
@ryanwachtl
ryanwachtl / _ss_environment.sample.php
Last active July 14, 2018 08:15
Configure SilverStripe using the _ss_environment.php file.
<?php
/**
* Configure SilverStripe from the _ss_environment.php file.
*
* Edit this file and rename from _ss_environment.sample.php to _ss_environment.php.
* Put "require_once('conf/ConfigureFromEnv.php');" into your _config.php file.
* http://doc.silverstripe.org/framework/en/trunk/topics/environment-management
*/
@ryanwachtl
ryanwachtl / SilverStripe Foundation HtmlEditorConfig
Last active December 21, 2015 04:39
HtmlEditorConfig for SilverStripe Foundation Theme. Also sets up a minimal, single line toolbar.
HtmlEditorConfig::get('cms')->setOptions(array(
"skin" => "default",
"style_formats" => array(
array(
"title" => "Lead",
"selector" => "p",
"classes" => "lead"
),
array(
"title" => "Subheader",
@ryanwachtl
ryanwachtl / deploy.rb
Created August 16, 2013 21:23 — forked from stojg/deploy.rb
# My ./config directory in silverstripe looks like this:
# ./503.php <- a 503 Maintainance page
# ./_ss_environment.php <- the production environment settings
# ./deploy.rb <- is the recipe below
#
# Application settings
set :application, "domain.com"
set :shared_children, %w(assets)
@ryanwachtl
ryanwachtl / _ss_environment.php
Last active August 31, 2016 02:23
Use server environment variables to setup your SilverStripe environment
<?php
/**
* Configure SilverStripe using apache environment variables
* Usage: Put "require_once('conf/ConfigureFromEnv.php');" into your _config.php file.
* Example Apache vhost:
* <VirtualHost *:80>
* ...
* SetEnv SS_ENVIRONMENT_TYPE dev
* SetEnv SS_DEFAULT_ADMIN_USERNAME admin
<?php
public function duplicate() {
$items_to_duplicate = array(
'Images',
'Somehting'
);
$page = parent::duplicate();
@ryanwachtl
ryanwachtl / SS-modelAdmin.php
Created January 16, 2016 19:49 — forked from dljoseph/SS-modelAdmin.php
SilverStripe 3.1.x add date range filters to modeladmin
<?php
class MyDataObjectAdmin extends ModelAdmin {
private static $managed_models = array('MyDataObject'); // Can manage multiple models
private static $url_segment = 'my-data-object'; // Linked as /admin/my-data-object/
private static $menu_title = 'My DataObjects';
public function getSearchContext() {