Skip to content

Instantly share code, notes, and snippets.

@rsanchez
rsanchez / gist:1855793
Created February 17, 2012 22:26
SafeCracker category checkboxes
{categories}
<input type="checkbox" value="{category_id}"{checked}>{category_name}</option>
{/categories}
@rsanchez
rsanchez / autocomplete.php
Created February 11, 2012 17:20
autocomplete.php
<?php
/**
* @property CI_DB_active_record $db
* @property CI_DB_forge $dbforge
* @property CI_Benchmark $benchmark
* @property CI_Calendar $calendar
* @property CI_Cart $cart
* @property CI_Config $config
* @property CI_Controller $controller
* @property EE_Email $email
@rsanchez
rsanchez / gist:1677069
Created January 25, 2012 16:26
preload replace channel
{preload_replace:chan="products"}
{exp:channel:entries channel="{chan}"}
{cf_{chan}_field_name}
{/exp:channel:entries}
@rsanchez
rsanchez / gist:1476795
Created December 14, 2011 14:30
ExpressionEngine Fieldtypes with custom DB tables
MX Google Map
Safe Harbor Polls
Matrix
Detour
Assets
Playa
Zoo Plus
CartThrob Order Items
Channel Files
Channel Images
@rsanchez
rsanchez / gist:1365099
Created November 14, 2011 20:46
session->cache do something just once
public Your_extension_ext
{
public function your_hook()
{
if ( ! isset($this->EE->session->cache['your_extension]))
{
//do your stuff
}
//set the cache, so next time your stuff won't run
<?php
if ( ! $this->EE->input->ajax_request())
{
show_404();
}
?>
@rsanchez
rsanchez / gist:1364133
Created November 14, 2011 15:12
Duplicate entry with Safecracker
{!--example url: template_group/template/123--}
{exp:safecracker entry_id="{segment_3}" return="template_group/template/ENTRY_ID"}
...
{!--
this is the trick that duplicates the entry
even though entry_id 123 is LOADED into this form
this blank entry_id field will trick SC into thinking
this is a new entry
@rsanchez
rsanchez / gist:1334725
Created November 2, 2011 20:04
CartThrob XML for Google Product Search
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0"
xmlns:g="http://base.google.com/ns/1.0">
<channel>
<title>{site_name} Products</title>
<link>{site_url}</link>
<description>[insert store description here]</description>
{exp:channel:entries channel="products" rdf="off" dynamic_start="on" limit="1000" disable="member_data|trackbacks"}
<item>
<title>{exp:xml_encode}{title}{/exp:xml_encode}</title>
@rsanchez
rsanchez / gist:1316752
Created October 26, 2011 15:46
Rackspace IP Address config hack for EE/CI
<?php
//add this to your config file
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
@rsanchez
rsanchez / gist:1226640
Created September 19, 2011 14:36
PHP current url ridiculousness
<?php
$url = (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on')?'https':'http'.'://'.$_SERVER['HTTP_HOST'].($_SERVER['SERVER_PORT'] != 80)?':'.$_SERVER['SERVER_PORT']:''.$_SERVER['REQUEST_URI'];