Skip to content

Instantly share code, notes, and snippets.

View muskie9's full-sized avatar

Nic muskie9

View GitHub Profile
<?php
public function onBeforeWrite(){
parent::onBeforeWrite();
$this->FullName = $this->FirstName . " " . $this->LastName;
}
---
Name: myConfig
After:
- 'framework/*'
- 'cms/*'
---
# YAML configuration for SilverStripe
# See http://doc.silverstripe.org/framework/en/topics/configuration
# Caution: Indentation through two spaces, not tabs
SSViewer:
<?php
$relations = $this->stat('has_many');
$dropdowns = [];
foreach($relations as $name => $obj){
$field = Dropdown::create($name)
->setTitle(Config::inst()->get($obj, 'singular_name'))
->setEmptyString('Select one')
LeftAndMain:
extra_requirements_css: [my-module-name/css/leftandmainextracss.css]
<?php
public function getCMSFields() {
$fields = Parent::getCMSFields();
$fields->addFieldToTab('Root.Compare Vehicles', new TextField('Title'));
$fields->addFieldToTab('Root.Compare Vehicles', LabelField::create('Model 1'));
//ArrayList::create(Car::get()->toArray())->RemoveDuplicates('MakesName');
$map = Car::get()->map('ID', 'MakesNiceName')->toArray();
$makes = new DropdownField('MakesName', 'MakesName', $map);
@muskie9
muskie9 / ListHelper.php
Created May 29, 2016 23:28
A utility class to help attach a field from related objects, via dot notation, that allows for filtering and grouped by list.
<?php
/**
* Class ListHelper
*/
class ListHelper
{
/**
* This method converts a {@link DataList} to an {@link ArrayList} with an option to add
@muskie9
muskie9 / SilverstripeDataObject.php
Created May 19, 2016 15:40 — forked from wernerkrauss/SilverstripeDataObject.php
Some PHPStorm / Intellij IDEA file templates for SilverStripe development
<?php
#parse("PHP File Header.php")
class ${NAME} extends DataObject {
private static \$db = array();
private static \$has_one = array();
private static \$has_many = array();
@muskie9
muskie9 / custom-search-acf-wordpress.php
Created May 12, 2016 15:09 — forked from charleslouis/custom-search-acf-wordpress.php
PHP - Wordpress - Search - wordpress custom search function that encompasses ACF/advanced custom fields and taxonomies and split expression before request
<?php
/**
* [list_searcheable_acf list all the custom fields we want to include in our search query]
* @return [array] [list of custom fields]
*/
function list_searcheable_acf(){
$list_searcheable_acf = array("title", "sub_title", "excerpt_short", "excerpt_long", "xyz", "myACF");
return $list_searcheable_acf;
}
<% if $EducationalPost %>
<% loop $EducationPost %>
<div class="description-block">
<h3>$Title</h3>
<img src="$MainImage.Filename">
<p>$Teaser</p>
<span class="clearfix"></span>
</div>
<% end_loop %>
<% else %>
<?php
$results = episode::getEpsThreeDays(date("Y-m-d 00:00:00", $startDate->format('U')));
$list = ArrayList::create();
foreach($results as $result){
$arrayListItem = ArrayData::create($result);
$list->push($arrayListItem);
}