Skip to content

Instantly share code, notes, and snippets.

View croxton's full-sized avatar
💭
Up to my elbows, as usual

Mark Croxton croxton

💭
Up to my elbows, as usual
View GitHub Profile
@croxton
croxton / gist:1010797
Created June 6, 2011 18:41
ExpressionEngine Stash match/against example
{!-- get a list of people with last names starting A-F --}
{exp:channel:entries channel="people" sort="asc" orderby="person_lname"}
{exp:stash:append name="people_a_f" match="#^[A-F]#" against="{person_lname}"}
<li><a href="/people/{entry_url}" title="view profile">{title}</a></li>
{/exp:stash:append}
{/exp:channel:entries}
@croxton
croxton / gist:1080050
Created July 13, 2011 10:22
Stash: persisting form values and caching
{!-- set context for this form to namespace our vars--}
{!-- @ refers to the current context --}
{exp:stash:context name="myform"}
{!-- register form variables from $_POST superglobal and save for 30 mins, scope to user's session --}
{exp:stash:get
name="filter"
dynamic="yes"
type="snippet"
save="yes"
@croxton
croxton / gist:1084483
Last active April 8, 2018 02:22
Sort on a Playa custom field in ExpressionEngine [HACK]
<?php
// Look for this in mod.channel.php (around line 2635):
case 'custom_field' :
if (strpos($corder[$key], '|') !== FALSE)
{
$end .= "CONCAT(wd.field_id_".implode(", wd.field_id_", explode('|', $corder[$key])).")";
}
else
{
@croxton
croxton / Tagger - Low search tweak
Created September 9, 2011 10:50
Tagger - Low search tweak
// ********************************************************************************* //
/**
* Preps the data for saving
*
* @param $data Contains the submitted field data.
* @return string Data to be saved
*/
public function save($data)
{
@croxton
croxton / Stash tip
Created September 9, 2011 16:42
Stash with Channel module: handling no results
{!-- build result rows --}
{exp:stash:set parse_tags="yes"}
{stash:results_rows}
{exp:channel:entries
channel="my_channel"
limit="10"
paginate="bottom"
}
<tr>
@croxton
croxton / Example Informer form config
Created October 13, 2011 09:19
Example Informer form config
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/*
|--------------------------------------------------------------------------
| Sample form field configuration
|--------------------------------------------------------------------------
*/
$config = array(
@croxton
croxton / stash multilingual
Created October 31, 2011 16:09
Stash: getting multilingual in your viewModel
{exp:channel:entries
limit="1"
disable="member_data|pagination|categories"
channel="page"
}
{!-- set fields based on language selection --}
{exp:switchee variable="{global:lang}" parse="inward"}
{!-- default language --}
@croxton
croxton / gist:1337243
Created November 3, 2011 18:12
Infomer Hooks
class Informer {
static protected $hooks = array();
protected $hook_event;
// --------------------------------------------------------------------
// Hook management
/**
* _register hook
@croxton
croxton / gist:1337517
Created November 3, 2011 19:22
Switchee with adjusted PCRE limit
<?php
$plugin_info = array(
'pi_name' => 'Switchee',
'pi_version' =>'2.0.4a',
'pi_author' =>'Mark Croxton',
'pi_author_url' => 'http://www.hallmark-design.co.uk/',
'pi_description' => 'Switch/case control structure for templates',
'pi_usage' => Switchee::usage()
);
@croxton
croxton / gist:1505601
Created December 21, 2011 10:53
User friendly modal windows for touch devices using Colorbox and Modernizr
$(document).ready(function(){
// colorbox
if ($('#modal').length > 0) {
var modalConfig = {
inline : true,
href : "#modal",
opacity : .75,
onLoad:function(){
$('#modal').css('display','block');