Skip to content

Instantly share code, notes, and snippets.

View tyssen's full-sized avatar

John Faulds tyssen

View GitHub Profile
@tyssen
tyssen / ee_responsive_images_template
Created July 19, 2011 12:56
Responsive images with ExpressionEngine template code
{exp:ce_img:pair src="{image}" max="{global:img_width}"}
{if global:img_width!=""}<a href="{image}">{/if}
<img src="{if global:img_width!=""}{made}{if:else}{image}{/if}" alt="">
{if global:img_width!=""}</a>{/if}
{/exp:ce_img:pair}
@tyssen
tyssen / modified_config_bootstrap
Created July 19, 2011 13:13
Modified Config Bootstrap to include img_width global variable
<?php
$default_global_vars['global:img_width'] = '';
$_mobileClients = array("android", "acer", "asus", "alcatel", "sie", "blackberry", "htc", "hp", "lg", "motorola", "nokia", "palm", "samsung", "sonyericsson", "zte", "mobile", "iphone", "ipod", "mini", "playstation", "docomo", "benq", "vodafone", "sharp", "kindle", "nexus", "windows phone","midp", "240x320", "netfront", "nokia", "panasonic", "portalmmm", "symbian", "mda", "mot-", "opera mini", "philips", "pocket pc", "sagem", "sda", "sgh-", "xda");
$mobile = false;
$userAgent = strtolower($_SERVER['HTTP_USER_AGENT']);
foreach ($_mobileClients as $mobileClient) {
@tyssen
tyssen / EE_page_template.php
Created August 13, 2011 00:45
Sample page template
{exp:channel:entries channel="site" url_title="{last_segment}" disable="categories|member_data|pagination|trackbacks"}
{embed="_embeds/index" body_class="{segment_1}" nav_active="{segment_1}" entry_id="{entry_id}"}
{exp:partials:set name="page_title"}{title}{/exp:partials:set}
{exp:partials:set name="content"}{body}{/exp:partials:set}
{/exp:channel:entries}
@tyssen
tyssen / grid-mixins.css
Created September 2, 2011 06:20
LESS baseline grid calculator mixins
@defaultfontsize: 16;
@defaultlineheight: @defaultfontsize*1.5;
.font(@fontsize:16,@lineheight:24,@multiplier:1,@lineheightreducer:1) {
font-size: (@fontsize/@defaultfontsize)*1em;
line-height: @lineheight/@fontsize/@lineheightreducer;
margin: (@lineheight/@fontsize*(@multiplier/(@lineheight/@defaultlineheight)))*1em 0 0;
}
.boxes(@paddingtop:1,@paddingbottom:1,@bordertop:0,@borderbottom:0) {
@tyssen
tyssen / grid-mixins-output.css
Created September 7, 2011 11:55
LESS baseline grid calculator mixin output
padding-top: 0.5625em; border-top-width: 3px;
padding-bottom: 0.5625em; border-bottom-width: 3px;
border-left-width: 3px;
border-right-width: 3px;
@tyssen
tyssen / gist:9498146
Created March 12, 2014 00:27
RESS with CE Image
{if ress>768}
{exp:ce_img:pair src="{image}" max_width="768"}
<img src="{made}" width="{width}" height="{height}" alt="">
{/exp:ce_img:pair}
{/if}
{if ress<=768}
{exp:ce_img:pair src="{image}" max_width="{ress}"}
<img src="{made}" width="{width}" height="{height}" alt="">
{/exp:ce_img:pair}
@tyssen
tyssen / gist:11249562
Last active August 29, 2015 14:00
Using SASS for creating mediaqueries
#content {
background-color: #fff;
clear: both;
overflow: hidden;
padding: 20px;
@include breakpoint(600) {
border: 2px solid $color1;
}
}
@tyssen
tyssen / gist:43f7218c0ca6ecdc32e3
Created August 2, 2014 04:05
Export XLS/CSV from EE template
<?php
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=enrolments.xls");
header("Pragma: no-cache");
header("Expires: 0");
?>
<table>
<thead>
<tr>
<th>First name</th>
{% set props = {
categories: props.categories.all() ??? null
} %}
{% set selectedCategories = props.categories %}
{# {% dd selectedCategories %} #}
{% set leafCategories = selectedCategories|filter(
category => selectedCategories|filter(current => category.isAncestorOf(current)) is empty
) %}
{# {% dd leafCategories %} #}