Skip to content

Instantly share code, notes, and snippets.

@GDmac
GDmac / gist:3216550
Created July 31, 2012 12:07
ExpressionEngine Snippets

ExpressionEngine Snippets

Safe_cracker Select author

<select name="author_id">
  {exp:query sql="SELECT member_id AS member_author_id, username AS member_username, screen_name AS member_screen_name FROM exp_members"}
  <option value="{member_author_id}" {if member_author_id == author_id}selected="selected"{if:elseif  member_author_id == logged_in_member_id}selected="selected"{/if}>{member_screen_name}</option>
  {/exp:query}
/* Event Helper, set an event to april first
* it won't show in the channel:entries
* but the archive wil show an entry for april
*/
{exp:channel:entries channel="events"
dynamic='no'
year='2012' month='04'
show_expired='yes' show_future_entries="yes"
}
@GDmac
GDmac / gist:2000022
Created March 8, 2012 09:49
CodeIgniter Curl Head first
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* This fetches the header only for a remote page.
*
* Pro's:
* - when fetching static stuff (images, css, html)
* you can first compare modified date or statuscode (304)
*
* Con's:
* - hitting a heavy webapp with dynamic content might be slow,
* you essentially hit the remote page two times
@GDmac
GDmac / eecms cats with posts
Created February 23, 2012 17:49
Mysql joining 3 tables with possible entries
$query = "
SELECT
c.cat_id, cat_name, count(t.status) AS count_posts
FROM
exp_categories c
LEFT JOIN exp_category_posts AS p
ON p.cat_id = c.cat_id
LEFT JOIN exp_channel_titles AS t
ON t.entry_id = p.entry_id
AND t.status != 'closed'
@GDmac
GDmac / fullcal_demo.html
Created December 25, 2011 15:45
EE full_calendar demo, regular channel entries
{!--
// -----------------------------------------------------------------------
// template_group/fullcal_demo
--}
<script type='text/javascript'>
// for start_on and stop_before parameters format 2011-12-25 13:00
function myDate(d) {
return d.getFullYear() + '-' +
(d.getMonth() < 9 ? '0' : '') + (d.getMonth()+1) + '-' +
@GDmac
GDmac / gw_categories select-menu
Created May 25, 2011 17:32
Select menu with gwcode_categories
[select name="category[]" id="categories" multiple="multiple"]
{exp:gwcode_categories channel="locations_channel" style="linear"}
{if "{new_group}"=="yes"}
{if {cat_count}>1}
[/optgroup]
{/if}
[optgroup label="{cat_group_name}"]
{/if}
[option value="{cat_id}"]{cat_name}[/option]
{/exp:gwcode_categories}