Skip to content

Instantly share code, notes, and snippets.

View LukeTowers's full-sized avatar
❄️
Building a snowman

Luke Towers LukeTowers

❄️
Building a snowman
View GitHub Profile
@LukeTowers
LukeTowers / backend.list.injectRowClass.php
Last active January 12, 2017 21:59
OctoberCMS Event Examples
<?php namespace Vendor\Plugin
use Event;
use Vendor\Plugin\Models\MyModel;
use Vendor\Plugin\Controllers\MyController;
class Plugin
{
public function boot()
{
@LukeTowers
LukeTowers / Frontend Flash Message Test
Created February 4, 2017 03:40
OctoberCMS Snippets
==
<?php
function onHandle() {
Flash::success('test');
}
?>
==
{# Doesn't work because no 'data-request' or 'data-request-flash' is set on the containing form #}
{{ form_open() }}
/**
* Group messages by thread id pulling message and thread ids from the provided $queryScopes Query object
*
* @param QueryBuilder $query QueryBuilder object to apply the scope to
* @param QueryBuilder $queryScopes QueryBuilder object to use to get the message ids from
* @return QueryBuilder $query
*/
public function scopeGroupedByThread($query, $queryScopes = null)
{
$queryScopes = $queryScopes ?: $this->newQuery();
StaffMembersController::extendFormFields(function($form, $model, $context) {
if (!$model instanceof StaffMemberModel) {
return;
}
// Get the model's profile, including any that may have been deferred already
$profile = $model->profile()->withDeferred($form->getSessionKey())->first();
// If the profile object for this user doesn't exist yet, then create it and add it via deferred binding if necessary
if (!$profile) {
@LukeTowers
LukeTowers / block-profile.htm
Created May 12, 2017 19:59
Render Repeater Groups
<div class="profile-square">
<h2 class="profile-title">{{ data.title }}</h2>
<div class="profile-description">{{ data.description }}</div>
<img class="profile-image" src="{{ data.image | media }}">
</div>
@LukeTowers
LukeTowers / StaticPage.php
Created August 14, 2017 19:27
Static Page display component
<?php namespace LukeTowers\Examples\Components;
use Config;
use Cms\Classes\Theme;
use Cms\Classes\ComponentBase;
use RainLab\Pages\Classes\Page as StaticPage;
class StaticPage extends ComponentBase
{
$data = array_dot(\Lang::get('iacea.exchanges::lang'));
$options = [];
/*
* Parse options
*/
$defaultOptions = [
'firstRowTitles' => true,
'useOutput' => false,
'fileName' => 'export.csv',
@LukeTowers
LukeTowers / Froala extension JS
Created June 13, 2017 23:55
October Tricks
/*
|------------------
| Extend Richeditor
|------------------
*/
+function ($) {
var Plugins = {
init: function () {
$.FroalaEditor.DefineIcon('buttonIcon', {NAME: 'star'});
$.FroalaEditor.RegisterCommand('myButton', {
# Get Remote URL
git config --get remote.origin.url
# Set Remote URL
git remote set-url origin ssh://git@github.com/captive/repository
# Initialize submodules
@LukeTowers
LukeTowers / Inline Styles.css
Last active November 16, 2018 17:16
Clean Gmail's crap new design
div[role="main"] > div:not(:last-child):not([class=""])[class] {
height: 2.25em;
}
div[aria-label="Side panel"] > div > div[role="tablist"] {
display: none;
}
div.no > div:last-child {
display: none;