Skip to content

Instantly share code, notes, and snippets.

GDmac GDmac

  • Netherlands
Block or report user

Report or block GDmac

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
GDmac /
Last active Aug 29, 2015
Mobile sharing buttons (app or website)

Sharing on the mobile platform

Many smartphone users (probably most) use dedicated apps for their social sharing. However, when clicking on a share button on websites, the user is redirected to the website instead of to the app for twitter and facebook. This document tries to offer an alternative route for sharing on mobile.

User story and technique

  1. When a user clicks the share button for the first time
    ask if he/she wants to use an app or to go to the website.
    Use local storage (jstorage) or cookies to store user preferences.
  2. When the user wants to use the app, use a small script to verify
GDmac /
Last active Aug 29, 2015
Protected Pages extension

ProtectedPages extension

Make sections of your site (template) accessible to members only.

Quick Setup

Create a template with a loginform and the processform tag. The form should at least provide username, password and action. e.g.:

GDmac / hello.php
Created May 25, 2014
Simple request
View hello.php
$req = parse_url($_SERVER['REQUEST_URI']);
// querystring
isset($req['query']) ? parse_str($req['query'], $req['query_arr']) : $req['query_arr'] = array();
// route
$req['route'] = substr($_SERVER['PHP_SELF'], strlen($_SERVER['SCRIPT_NAME']));
GDmac / gw_categories select-menu
Created May 25, 2011
Select menu with gwcode_categories
View gw_categories select-menu
[select name="category[]" id="categories" multiple="multiple"]
{exp:gwcode_categories channel="locations_channel" style="linear"}
{if "{new_group}"=="yes"}
{if {cat_count}>1}
[optgroup label="{cat_group_name}"]
[option value="{cat_id}"]{cat_name}[/option]
GDmac / fullcal_demo.html
Created Dec 25, 2011
EE full_calendar demo, regular channel entries
View fullcal_demo.html
// -----------------------------------------------------------------------
// 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 / eecms cats with posts
Created Feb 23, 2012
Mysql joining 3 tables with possible entries
View eecms cats with posts
$query = "
c.cat_id, cat_name, count(t.status) AS count_posts
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 / gist:2000022
Created Mar 8, 2012
CodeIgniter Curl Head first
View gist:2000022
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* 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
View gist:2215989
/* 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"
year='2012' month='04'
show_expired='yes' show_future_entries="yes"
GDmac / gist:3216550
Created Jul 31, 2012
ExpressionEngine Snippets
View gist:3216550

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>
GDmac / gist:3667859
Created Sep 7, 2012
EE Preload replace double trick
View gist:3667859

main template

{embed="group/template" preload='{{preload_trick}:pre_url_title="special"}'}

embedded template

if called via embed you can override the preload_replace once more.
It will insert the embed-variable and parse it early.

{if segment_3==""}{preload_replace:pre_url_title="fallback"}{/if}

You can’t perform that action at this time.