Skip to content

Instantly share code, notes, and snippets.

View croxton's full-sized avatar
💭
Up to my elbows, as usual

Mark Croxton croxton

💭
Up to my elbows, as usual
View GitHub Profile
@croxton
croxton / bottrapips.txt
Created May 4, 2016 09:21
Bot Trap IPs captured May 2015 - May 2016
123.125.71.87
123.125.71.83
86.178.200.107
80.56.101.37
89.123.45.57
174.127.132.146
174.127.132.148
61.140.166.237
89.123.5.255
89.123.55.141
@croxton
croxton / nesting_ee_blocks_with_stash.md
Created November 25, 2015 10:09
Nesting EE blocks with Stash
{project_gallery}

	{!-- section --}
	{bk_gallery_section}

		<section class="gallery">

			{!-- save count of current section --}
			{exp:stash:set_value name="section_index" value="{blocks:count:of:type}" random}
@croxton
croxton / gist:a4b6110d5bb6ce64ca16
Last active April 8, 2018 02:24
Evaluating globals with Switchee
{exp:channel:entries...}

	{!-- assumming /my/url?statement_id=... --}

	{exp:switchee name="get:statement_id" parse="inward"}

		{!-- match 0-50 --}
		{case value="#^[0-9]$#|#^[1-4][0-9]$#|#^50$"}
			{switchee variable="{statement_factor}" parse="inward"}

{case value="Agree"}

@croxton
croxton / gist:7773beb5fe44d9f9a66a
Last active April 8, 2018 02:24
Previews with Resource Router

###Secure previews of draft entries with Resource Router

  1. Make a copy of index.php and call it preview.php. Add any custom config values in preview.php that you might like when previewing entries, such as disabling caching.

  2. Create a rule for Resource Router that looks something like this:

    $config['resource_router'] = array(
    
    	// match any url
@croxton
croxton / cloudinary_reponsive_background_cover_img
Last active November 1, 2019 10:36
Responsive background cover images with Cloudinary & jQuery, fetched on the fly
HTML:
<header id="js-cover" class="cover">
<!-- Optionally specify image width stoppoints to reduce the maximum possible no of transforms per image -->
<!-- The appropriate image resolution will automatically be loaded -->
<img
data-stoppoints="480,768,1200"
data-src="http://res.cloudinary.com/<your account name>/image/fetch/w_auto,dpr_auto/http://<your full img url>"
class="cld-responsive cover-img" id="js-cover-img">
@croxton
croxton / .htacess
Last active April 8, 2018 02:24
htacess static caching with Stash / Mustash + Apache web performance
# ######################################################################
# # REWRITE RULES #
# ######################################################################
<IfModule mod_rewrite.c>
RewriteEngine On
#################################################################################
# Redirect to canonical domain
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if( ! defined('PATH_THIRD')) { define('PATH_THIRD', APPPATH . 'third_party'); };
/**
* Zenbu Transcribe support extension
* =========================================
* Enables display of Transcribe language for the entry in Zenbu
* @version 1.0.0
* @author Koen Veestraeten (@StudioKong)
* Based on the examples Zenbu MX Cloner and Zenbu Tag Formatting provided by Nicolas Bottari
* Zenbu MX Cloner: https://github.com/nicolasbottari/zenbu_mx_cloner.zenbu_addon.ee2_addon
protected $hooks = array(
'@all' => array(
'member_id',
'screen_name',
'username',
'group_id',
'group_title'
),
@croxton
croxton / calendar.html
Last active April 8, 2018 02:23
Solspace Calendar availability
{!--
These vars are used as a workaround for a bug in Solspace Calendar that causes
whitespace around if/else conditionals inside {events}...{/events} to be removed.
--}
{exp:stash:first_day_ph}first_day first_day{/exp:stash:first_day_ph}
{exp:stash:last_day_ph}last_day last_day{/exp:stash:last_day_ph}
{exp:stash:open}open {/exp:stash:open}
{exp:stash:Provisional}provisional {/exp:stash:Provisional}
{!-- Availability calendar --}
<?php
/**
* Routes
*
* Defines rules for routing requests to templates
*
*/
$env_config['resource_router'] = array(
/* ---------------------------------------------------------