Skip to content

Instantly share code, notes, and snippets.

// P&T link automations
var ee_affiliate_name = 'brandonkelly',
external_re = new RegExp('^https?://(?!'+document.location.hostname+')'),
external_ee_re = new RegExp('^(https?://(secure\\.)?expressionengine.com\\/)([^#]*)(#(\\w+))?$'),
ee_affiliate_re = new RegExp('^index\\.php\\?affiliate='+ee_affiliate_name);
$('a').each(function(){
// is this an external link?
if (this.href.match(external_re)) {
{exp:channel:entries channel="ee" url_title="{segment_3}" limit="1"}
{if no_results}{embed="site/404"}{/if}
{exp:docs:page entry_id="{entry_id}" url_title="{segment_4}"}
{if no_page}{embed="site/404"}{/if}
{embed="site/-header" title="{title} - Docs - {docs_page_title}" id="{url_title}-docs" class="ee docs"}
<header class="clearafter">
<hgroup class="left">
A Guide to Fieldtype Settings in EE2
display_global_settings()
- $this->settings
- fieldtype's global settings
display_settings($data)
- $this->settings
- fieldtype's global settings
/**
* tabfocus event plugin for jQuery
*
* Mimics the focus() event, except it's only
* called when focus wasn't assigned via a click
*
* -------------------------------------------
* Usage
* -------------------------------------------
*
@brandonkelly
brandonkelly / gist:2723569
Created May 18, 2012 06:31
Remove <script> tags from HTML
// Remove any <script> tags
// Go backwards to factor in nested script tags, e.g. <script>document.write('<script></script>')</script>
$offset = strlen($html) - 9; // Minimum match length is 9 chars (<script/>)
for ($offset; $offset >= 0; $offset--)
{
$substr = substr($html, $offset);
if (preg_match('/^<script[^>]+?\/>|^<script(?:.|\s)*?\/script>/im', $substr, $match))
{
$html = substr($html, 0, $offset).substr($html, $offset+strlen($match[0]));
}
@brandonkelly
brandonkelly / wygwam-trim
Created June 22, 2012 19:26
Trim out whitespace when saving a Wygwam field
In system/expressionengine/third_party/wygwam/ft.wygwam.php, find this in the beginning of the save() function:
// Clear out if just whitespace
if (! $data || preg_match('/^\s*(<\w+>\s*(&nbsp;)*\s*<\/\w+>|<br \/>)?\s*$/s', $data))
{
return '';
}
And replace it with this:
@brandonkelly
brandonkelly / assets2-simple-file-input.html
Created January 15, 2013 21:10
Here's how to create a simple file upload input for an Assets 2 field in SafeCracker
<input type="file" name="fieldname">
<input type="hidden" name="fieldname_filedir" value="1">
@brandonkelly
brandonkelly / gist:5643159
Created May 24, 2013 12:27
Upcoming BaseOptionsFieldType templating options
{% if entry.drinkAttributes.contains('alcoholic') %}
Alcoholic!
{% else %}
Not alcoholic
{% endif %}
<h2>Selected Attributes</h2>
<table>
{% for attr in entry.drinkAttributes %}
<tr>
@brandonkelly
brandonkelly / gist:5722967
Created June 6, 2013 16:42
New getNext() / getPrev() support coming to all elements in Craft 1.1
{% set criteria = {section: 'cocktails', order: 'title'} %}
{% set prev = entry.getPrev(criteria) %}
{% set next = entry.getNext(criteria) %}
{% if prev or next %}
<div class="pane">
{% if prev %}
<p>Previous: <a href="{{ prev.url }}">{{ prev.title }}</a></p>
{% endif %}
## Getting Started
* Introduction
* Installing & Updating
- Requirements
- Installing
- Updating
* Licensing
* CP Overview
* Packages & Plugins