Skip to content

Instantly share code, notes, and snippets.

@airways
airways / gist:2484930
Created April 25, 2012 00:40
ProForm state selection
This is an example for how to display the label selected for a dropdown value
in the notification template. It is a bit verbose in the template code,
so I am planning to add a new option soon which will make extracting the
selected label as easy as getting the selected value.
Screenshots showing how to setup the form and the field to send an email to
the address set as the value for the same dropdown field:
Field settings for a field named "state":
* https://skitch.com/blueapples/8iwir/state-notification-field
@airways
airways / gist:2621942
Created May 6, 2012 12:07
Proposed filter_extensions hook and example
<?php
/////////////////////////////////////////////
// Added hook call to EE_Extensions:
/////////////////////////////////////////////
class EE_Extensions {
...
function __construct()
{
$this->EE =& get_instance();
@airways
airways / widget.c
Created May 16, 2012 14:15
Base widget methods for Allegro 5 (source unknown)
#include "widget.h"
//total event controllers
#define MAX_EVENT_CONTROLLERS 10
//event controller
typedef struct EVENT_CONTROLLER
{
@airways
airways / gist:3080850
Created July 10, 2012 03:48
VS Members Filtering for Playa
./system/expressionengine/third_party/playa/
diff /Volumes/HDD/Installers/CMS/EE/Playa4.3/Playa4/ee2/third_party/playa/ft.playa.php ./system/expressionengine/third_party/playa/ft.playa.php
1152a1153
> array_unshift($authors, array('id' => 'related', 'title' => '&mdash; '.lang('related').' &mdash;'));
1525a1527,1592
> // Related author?
> // -------------------------------------------
>
> $add_to_sql = array();
> if (($key = array_search('related', $this->settings['authors'])) !== FALSE)
@airways
airways / mod.structure.php
Created February 17, 2013 21:01
Calling {exp:structure:entries} with a parent_id parameter that does not have any children results in all entries from the site tree being returned, instead of nothing, which is what I would expect. This patch fixes this by setting the entry_id parameter to an impossible value.
function entries() {
$parent_id = $this->EE->TMPL->fetch_param('parent_id', false);
if ($parent_id) {
$child_ids = $this->sql->get_child_entries($parent_id);
$fixed_order = $child_ids !== FALSE && count($child_ids > 0) ? implode('|', $child_ids) : false;
if ($fixed_order) {
$this->EE->TMPL->tagparams['fixed_order'] = $fixed_order;
@airways
airways / gist:5882120
Created June 28, 2013 02:49
One day...
{ce:core:foreach in=beans}
<tr>
{ce:core:foreach in=loop_value}
{if loop_key == table_id}
<td>[{table_id}] {loop_key} = <a href="{cp_url}publish/edit/{type}/{loop_value}">{loop_value}</a></td>
{if:else}
{if loop_key == 'title'}
<td>title {loop_key} = <a href="{cp_url}publish/edit/{type}/{bean_id}">{loop_value}</a></td>
{if:else}
{if loop_key != 'loop_key' & loop_key != 'parent_id' & loop_key != 'bean_id'}
{ce:core:recurse in=tree children_field="__children"}
{loop_items}
<li>
<span><a href="{cp_url}publish/edit/{__type}/{__id}">{title}</a></span>
{if __children}
<ul>
{__children}
</ul>
{/if}
</li>
@airways
airways / proform_view.php
Created July 27, 2013 16:48
Fix for pre EE 2.6
<?php
class PF_View extends View {
public function __construct(View $view)
{
if(!isset($this->EE)) $this->EE = &get_instance(); // <-- Add this line
$this->set_cp_theme($view->_theme);
}
public function head_title($title)
@airways
airways / with_stash.html
Last active August 29, 2015 14:16
Stash comparison
<div class="section sticky_nav">
<div class="filter_nav">
<ul>
{!-- category 2 -- a post type --}
{!-- build url so far --}
{exp:stash:set name="filter_base1"}{site_url}{segment_1}{if router_blog_name != ""}/{router_blog_name}{/if}/{if router_cat1 != ""}{router_cat1}{if:else}all{/if}{/exp:stash:set}
<li class="{if router_cat2_category_url_title == ''}active{/if}"><a href="{exp:stash:filter_base1 random}/all/">All Results</a></li>
{exp:channel:categories category_group="3" style="linear"}
@airways
airways / gist:888cfea54e19ec2fcde1
Last active August 29, 2015 14:16
Handle manager for ExpressionEngine - returning objects from an add-on
// Field: Returning an array or object as a variable, for instance in a fieldtype
ee()->load->library('handle_manager');
$results = ee()->db->get('table_mapping')->results();
$table_pattern = array(
"table_data" => ee()->handle_manager->register($results) // Returns a handle, e.x.: {&100}
);
ee()->TMPL->parse_variables($tagdata, array($table_pattern));
{!-- Take the array of data in the table_data variable and pass it as a parameter to the plugin --}
{meta_table}