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 / 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', {
@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
{
@LukeTowers
LukeTowers / .gitignore
Last active February 27, 2021 23:40
OctoberCMS Tricks
/bootstrap/compiled.php
/vendor
composer.phar
.DS_Store
.idea
.env
.env.*.php
.env.php
php_errors.log
nginx-error.log
$data = array_dot(\Lang::get('iacea.exchanges::lang'));
$options = [];
/*
* Parse options
*/
$defaultOptions = [
'firstRowTitles' => true,
'useOutput' => false,
'fileName' => 'export.csv',
@LukeTowers
LukeTowers / .0 - cheatsheet.sh
Last active February 6, 2023 20:58
Introduction to OctoberCMS
# Setup symlinks in local development copy of Winter to the local development copy of Winter.Workshop
ln -s ~/LocalRepositories/WinterCMS/Themes/Winter/Workshop ~/LocalRepositories/WinterCMS/Core/winter/themes/workshop
# Setup external symlink (for mac, outside of vagrant) to the local development copies of my plugins
ln -s ~/Repositories/WinterCMS/Themes/Winter/Workshop ~/Repositories/WinterCMS/Core/winter/themes/workshop-src
# Setup symlinks in local development copy of Winter to the local development copies of my plugins
ln -s ~/LocalRepositories/WinterCMS/Plugins ~/LocalRepositories/WinterCMS/Core/winter/plugins
# Setup external symlink (for mac, outside of vagrant) to the local development copies of my plugins