Skip to content

Instantly share code, notes, and snippets.

Avatar

Ryan Wachtl ryanwachtl

View GitHub Profile
@ryanwachtl
ryanwachtl / SS-modelAdmin.php
Created Jan 16, 2016 — forked from dljoseph/SS-modelAdmin.php
SilverStripe 3.1.x add date range filters to modeladmin
View SS-modelAdmin.php
<?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() {
View silverstripe_duplicate_relations.php
<?php
public function duplicate() {
$items_to_duplicate = array(
'Images',
'Somehting'
);
$page = parent::duplicate();
@ryanwachtl
ryanwachtl / _ss_environment.php
Last active Aug 31, 2016
Use server environment variables to setup your SilverStripe environment
View _ss_environment.php
<?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
View README.md
View 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 / SilverStripe Foundation HtmlEditorConfig
Last active Dec 21, 2015
HtmlEditorConfig for SilverStripe Foundation Theme. Also sets up a minimal, single line toolbar.
View SilverStripe Foundation HtmlEditorConfig
HtmlEditorConfig::get('cms')->setOptions(array(
"skin" => "default",
"style_formats" => array(
array(
"title" => "Lead",
"selector" => "p",
"classes" => "lead"
),
array(
"title" => "Subheader",
@ryanwachtl
ryanwachtl / _ss_environment.sample.php
Last active Jul 14, 2018
Configure SilverStripe using the _ss_environment.php file.
View _ss_environment.sample.php
<?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 / composer.json
Last active Dec 14, 2015
Boilerplate for a SilverStripe theme or module composer.json file.
View composer.json
{
"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 }}"
}],
View getURLParameter.js
//parameter or returns an empty string
jQuery.getURLParameter = function(name) {
return decodeURI(
(RegExp(name + '=' + '(.+?)(&|$)').exec(location.search) || [, ''])[1]
);
};
@ryanwachtl
ryanwachtl / (MiniCartItemShortcodeHandler) MiniCart.php
Created Oct 17, 2011
SilverStripe PayPal Mini Cart Integration
View (MiniCartItemShortcodeHandler) MiniCart.php
<?php
class MiniCart extends DataObjectDecorator {
...
public static function MiniCartItemShortcodeHandler($attributes, $content = null, $parser = null) {
if(empty($attributes['name']) || empty($attributes['price'])) {
return;