Skip to content

Instantly share code, notes, and snippets.

View brendo's full-sized avatar
👶
Paternity Leave, back Dec 7

Brendan Abbott brendo

👶
Paternity Leave, back Dec 7
View GitHub Profile
@brendo
brendo / symphonydelgates.md
Created May 10, 2011 10:52
DelegateExecutionOrder

Requesting {$root}/page-one/

  • FrontendInitialised
  • FrontendPrePageResolve
  • FrontendPageResolved
  • FrontendParamsResolve
  • FrontendProcessEvents
  • EventPreSaveFilter (for each Event executed)
  • EventPostSaveFilter (for each Event executed)
  • EventFinalSaveFilter (for each Event executed)
@brendo
brendo / script_texthtml.md
Created February 18, 2012 04:11
Using <script type='text/html'>

Using <script type='text/html'>

While looking for a more manageable way to maintain my Mustache templates, I came across the icanhaz, which promotes putting your templates in your DOM using:

<script type='text/html' id='your-template>
    // Template in here
</script>

Being a bit of a performance nut, I was nervous about putting my templates into the DOM like this for a couple of reasons:

@brendo
brendo / backend.html
Created April 13, 2012 15:14
Symphony Backend markup
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<!-- Core styles -->
<link rel="stylesheet" type="text/css" media="screen" href="http://example.com/symphony/assets/css/symphony.css">
<link rel="stylesheet" type="text/css" media="screen" href="http://example.com/symphony/assets/css/symphony.legacy.css">
<link rel="stylesheet" type="text/css" media="screen" href="http://example.com/symphony/assets/css/symphony.grids.css">
@brendo
brendo / EventTutorial.md
Created April 4, 2011 11:06
Symphony Events: A Detailed Look

Forms have been an integral part of any interactive site since the dawn of time, they promote interactivity and are usually the most common way users interact with a site. It's commonplace that when a form is submitted, the website will take 'action' and do something with the data and then provide a user with the result. Symphony provides this logic layer via Events.

This tutorial assumes you have a basic understanding of how Events work in Symphony (if not, this may be a good introduction) and are semi comfortable writing some PHP code. I'll be showing you some of the lesser known features of Symphony Events, including event priority, event chaining and a brief demonstration of how to write a custom Event. The difficulty level progresses as we go through, but with any luck you'll be able to learn a thing or two :)

Getting Started

The Scenario

Our client requires a form that allows a user to submit some details about their new car purchase. Th

@brendo
brendo / class.rewrite.php
Created March 10, 2012 18:42
PHP 5.4 Router
<?php
/**
* @package toolkit
*/
/**
* URL rewriter for use in conjunction with the PHP 5.4 internal HTTP server and `rounter.php`.
*/
namespace Rewrite;
@brendo
brendo / class.autocomplete.php
Created September 29, 2011 12:46
RL Autocomplete
<?php
Class contentExtensionReferencelinkAutocomplete extends AjaxPage{
public function handleFailedAuthorisation(){
$this->_status = self::STATUS_UNAUTHORISED;
$this->_Result = json_encode(array('status' => __('You are not authorised to access this page.')));
}
public function view(){
<data>
<people>
<item id='1'>Fred</item>
<item id='2'>Jane</item>
<item id='3'>Bob</item>
<item id='4'>Mary</item>
<item id='6'>Tom</item>
</people>
<people-details>
<entry id='1'>
// Connect 4
// 7 across, 6 down
//
// | | | | | | | |
// | | | | | | |
//
const board = [
[0, 0, 0, 0, 0, 0, 0],
@brendo
brendo / symphony222.md
Created May 12, 2011 11:47
Symphony 2.2.2 Release Notes

Release Candidate 1

Improvements

  • #706 - Previously when deleting a large number of entries using 'Delete Entries' which caused PHP to reach it's maximum memory usage, no entries would be deleted making it impossible to delete entries through the Symphony administration. Entry deletion is now processed in batches of 2500, so should the memory limit be hit, at least some of the entries will be deleted. The entryDataCleanup function also now supports an array of entry_id rather than a single entry_id
  • The EventPreSaveFilter now gets passed the $entry_id when an Event is editing entries. This will be null on new entries
  • Sometimes '0' was interpreted as empty by the default checkPostFieldData implementation
  • Add __get() to the EmailGateway allowing variables to be accessed once they are set
  • Ongoing documentation tweaks
@brendo
brendo / EventTutorial.md
Created May 23, 2011 09:40 — forked from nickdunn/EventTutorial.md
Symphony Events: A Detailed Look

Forms have been an integral part of any interactive site since the dawn of time — they promote interactivity and are usually the most common way users interact with a site. It's commonplace that when a form is submitted (input), the website will take 'action' and do something with the data (processing) and then provide a user with the result (output). Symphony provides this logic layer via events.

This tutorial is about customising Symphony events. You will learn about:

  • event execution conditions (load and __trigger)
  • field naming and the $_POST array
  • creating related entries in two or more sections at the same time, aka. event chaining
  • event priority (execution order)
  • entirely custom events