Skip to content

Instantly share code, notes, and snippets.

@litzinger
litzinger / matrix.diff
Created February 16, 2012 13:25
Matrix and Playa diffs for hooks
diff -rupN /Users/litzinger/Dropbox/add-ons/_others/Matrix2.2.4/ee2/third_party/matrix/ft.matrix.php matrix/ft.matrix.php
--- /Users/litzinger/Dropbox/add-ons/_others/Matrix2.2.4/ee2/third_party/matrix/ft.matrix.php 2012-01-24 11:17:48.000000000 -0600
+++ matrix/ft.matrix.php 2012-02-15 21:11:48.000000000 -0600
@@ -1494,7 +1494,20 @@ class Matrix_ft extends EE_Fieldtype {
$this->EE->db->limit($max_rows);
}
- $query = $this->EE->db->get('matrix_data')->result_array();
+ // -------------------------------------------
+ // 'matrix_display_query' hook
@litzinger
litzinger / .htaccess
Created February 29, 2012 19:10
Add trailing slashes
# Add trailing slashes unless it's a file or has a query string.
RewriteCond %{THE_REQUEST} ^GET
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule ^(.*)$ $1/ [L,R=301]
# Do our rewrites
RewriteBase "/"
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
@litzinger
litzinger / clone.php
Created March 1, 2012 21:54
Clone publish layouts
<?php
$field_display = array(
'visible' => TRUE,
'collapse' => FALSE,
'html_buttons' => TRUE,
'is_hidden' => FALSE,
'width' => '100%'
);
$data = array(
@litzinger
litzinger / date.js
Created March 8, 2012 02:29
Cross Domain XML to JSON
/*
* JavaScript Pretty Date
* Copyright (c) 2011 John Resig (ejohn.org)
* Licensed under the MIT and GPL licenses.
*/
// Takes an ISO time and returns a string representing how
// long ago the date represents.
function prettyDate(time){
var date = new Date((time || "").replace(/-/g,"/").replace(/[TZ]/g," ")),
@litzinger
litzinger / advanced.html
Created March 16, 2012 16:24
Simple EE template example
{!-- Redirect to the registration page if logged out and trying to access the account page --}
{if segment_1 == "account" AND logged_out == TRUE}
{redirect="account/register-full"}
{/if}
{exp:channel:entries status="{global:default_status}" disable="{global:disabled_params}"}
{snippet:_header}
<div class="main-wrapper">
@litzinger
litzinger / config.php
Created March 16, 2012 19:06
Optimized EE configuration files
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
|--------------------------------------------------------------------------
| ExpressionEngine Config Items
|--------------------------------------------------------------------------
|
| The following items are for use with ExpressionEngine. The rest of
| the config items are for use with CodeIgniter.
|
@litzinger
litzinger / plugin-tag-example.php
Last active October 2, 2015 17:47
Example of how to create a plugin tag with nested loops and prefixed variables.
<?php
/* Usage
{exp:kaplan:categories
products="55,56,52,53,54,65"
state="{url:segment_2_category_id}"
variable_prefix="category:"}
{if no_results}{/if}
@litzinger
litzinger / ft.structure.php
Created April 6, 2012 15:40
Custom StructureFrame
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Structure Fieldtype
*
* This file must be in your /system/third_party/structure directory of your ExpressionEngine installation
*
* @package StructureFrame for EE2
* @author Jack McDade (jack@jackmcdade.com)
* @copyright Copyright (c) 2012 Travis Schmeisser
@litzinger
litzinger / cron.php
Created April 18, 2012 18:04
Call EE actions via cron
<?php
/*
Cheap way to fire off EE's ACT events in a crontab, and without having
to make any other changes to bootstrap EE to work in CLI.
*/
if (isset($_SERVER['SERVER_NAME']) || PHP_SAPI !== "cli") die();
$args = $argv;
@litzinger
litzinger / ext.hook_example.php
Created April 25, 2012 14:36
Example of an EE extension hook to replace an {exp:channel:entries} custom field variable.
<?php
/*
Replace any template tags as needed
*/
function channel_entries_tagdata($tagdata, $row, &$channel)
{
// has this hook already been called?
if (isset($this->EE->extensions->last_call) && $this->EE->extensions->last_call)
{
$tagdata = $this->EE->extensions->last_call;