Skip to content

Instantly share code, notes, and snippets.

@erikreagan
erikreagan / ExpressionEngine Body Tags
Created October 5, 2009 12:59
ExpressionEngine Body Tags
<!-- A few samples of body tag use in ExpressionEngine templates -->
<!-- This uses embedded variables if they are sent from another template. I use this one often -->
<body{if embed:body_id} id="{embed:body_id}"{/if}{if embed:body_class} class="{embed:body_class}"{/if}>
<!-- This works well when sticking to the template_group/template structure -->
<body{if segment_1 !=''} id="{segment_1}"{if segment_2 != ''} class="{segment_2}"{/if}{/if}>
@erikreagan
erikreagan / tm-serialization-command1.php
Created October 27, 2009 21:28
Work with serialized data easier
#!/usr/bin/env php
<?php
// This command simply prints out the serialized data in a readable printed array format
// Found on a blog via a google search
// @see http://top-frog.com/2009/08/28/quickly-unserialize-data-in-textmate/
$data = unserialize(file_get_contents('php://stdin'));
print_r($data);
#!/usr/bin/env php
<?php
// this is a TextMate command that converts { and } characters to the HTML entities so they don't get parsed in docs
$matches = array('{','}');
$replacements = array('&#123;','&#125;');
echo str_replace($matches,$replacements,$_ENV['TM_SELECTED_TEXT']);
<?php
// The function strlen() returns the interger value of the string length within the parentheses
// We can string multiple together with math operators for equations
// PHP enabled in template
// Parsing Stage: Output
// Simple conditional here
// We group the strlen values in parentheses to get their value
// Why would example 1 work, but example 2 not work? (only difference is the opacity property)
// jQuery 1.4.2 in use
// Example 1
$("ul.pagination li a").hover(
function(){
$(this).siblings('.thumb').animate({
top: "-80px",
opacity: 'toggle'
},500);
@erikreagan
erikreagan / template-loader.php
Created October 22, 2010 08:27
EE template to serve as "base" templates which see if a country-specific version is available (multi-lingual site). If not then the "default" version is loaded.
{!--
/**
* This is a template loader for our multi-lingual / multi-regional site
* It takes pieces of parameters and assembles them into template_group/template format
* Then checks the DB to see if such a template exists. If it does then it returns the TRUE stuff
* If the template does NOT exist it returns the FALSE stuff
* It can be run as a single template tag to return "y" or "n" on if it exists OR
* it can be run as a tag pair to return other data based on the result
*
* A small custom plugin was written for this functionality
@erikreagan
erikreagan / acc.accessory_test.php
Created December 10, 2010 12:28
Sample accessory with ajax method for EE 2.x
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
// sample code for thread http://expressionengine.com/forums/viewthread/174318/
class Accessory_test_acc
{
public $name = 'Test Accessory';
public $id = 'accessory_test_acc';
public $version = '1.0.0';
public $description = 'Test bed for accessories';
@erikreagan
erikreagan / ee-php-comments.php
Created March 28, 2011 15:01
Comments in an ExpressionEngine core file
<?php
// There is a possiblity that there will be three extensions for a given
// hook and that two of them will call the same class but different methods
// while the third will have a priority that places it between those two.
// The chance is pretty remote and I cannot think offhand why someone
// would do this, but I have learned that our users and developers are
// a crazy bunch so I should make shite like this work initially and not
// just fix it later.
<?php
class Haddaway extends Songs_in_code {
public $love;
private $beat;
private $girl;
public function __construct()
{
<?php
if ($this->_EE->extensions->active_hook('deployment_hooks_'.$which.'_deploy') === TRUE)
{
$ext_response = $this->_EE->extensions->call('deployment_hooks_'.$which.'_deploy');
$this->response = is_array($ext_response) ? array_merge($this->response,$ext_response) : $this->response ;
}
?>