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
<?php
* --------------------------------------------------------------------
* CUSTOM CONFIG VALUES
* --------------------------------------------------------------------
// enable file sync for previews
$assign_to_config['stash_file_sync'] = TRUE;
@croxton
croxton / gist:cea020d5e9c5ee77192c
Last active April 8, 2018 02:23
Related entries fragment inside cached
{exp:stash:cache}
{exp:channel:entries limit="1" ...}
{!-- related entries --}
{stash:nocache}
{exp:stash:set_list
name="st_fbox_rels"
context="@URI"
bundle="related_items"
@croxton
croxton / gist:9638877
Created March 19, 2014 10:11
EE .gitignore
# Images #
##########
/public_html/images/captchas/*
/public_html/images/made/*
/public_html/images/remote/*
/public_html/images/member/*
/public_html/images/smileys/*
/public_html/images/avatars/uploads/*
/public_html/uploads/*
@croxton
croxton / stash_save_pref.md
Last active April 8, 2018 02:23
Saving user preferences with Stash + jQuery

Create a template such as site/save_preference with the following code - adjust the regex to suit your needs:

{exp:switchee variable="{segment_3}" parse="inward"}
	{!-- allow an alphanumeric name (and - or _) for the preference key only --}
	{case value="#^[a-zA-Z0-9-_]+$#"}
		{!-- allow a numeric value only --}
		{exp:stash:set name="{segment_3}" type="snippet" save="yes" scope="user" match="#^[0-9]+$#"}{segment_4}{/exp:stash:set}
	{/case}
{/exp:switchee}
@croxton
croxton / circle.svg
Last active September 10, 2024 05:57
Passing parameters to a SVG when used as an object, while still being able to use as an image.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@croxton
croxton / gist:7153533
Last active April 8, 2018 02:24
Spoofing the session
// Pretend to be a SuperAdmin.
// Don't really do this, setup a member group and account with the minimum permissions needed
$this->EE->session->userdata['group_id'] = 1;
$this->EE->session->userdata['member_id'] = 1;
$this->EE->session->userdata['can_delete_self_entries'] = 'y';
$this->EE->session->userdata['can_delete_all_entries'] = 'y';
@croxton
croxton / mod.my_module.php
Last active April 8, 2018 02:24
Loading a specific language file for a 3rd party add-on module
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class My_module {
protected $class_name;
function __construct()
{
$this->class_name = strtolower(__CLASS__);
@croxton
croxton / leaflet_custom_zoom_levels.js
Last active May 20, 2022 16:13
Leaflet custom zoom levels
/*
Most map tile providers use 256px square tiles so Leaflet's basic zoom algorithm looks like this:
256 * Math.pow(2, zoom);
If you're working with vector layers you can extend one of leaflet's default CRSs
and make it return tile sizes in smaller increments. This can be very helpful when using
fitBounds() with layer groups, so the zoomed group fits better within the map bounds:
E.g., extending L.CRS.EPSG3857 (the default CRS):
@croxton
croxton / entries_archive.md
Last active April 8, 2018 01:30
Sort a list of entries by year and then by month
	{exp:stash:set_list name="entries" parse_tags="yes"}
		{exp:channel:entries channel="my_channel" orderby="date" sort="desc" dynamic="no" limit="999"}
		    {stash:title}{title}{/stash:title}
		    {stash:date_day}{entry_date format="%d"}{/stash:date_day}
		    {stash:date_month}{entry_date format="%m"}{/stash:date_month}
		    {stash:date_year}{entry_date format="%Y"}{/stash:date_year}
		    {stash:date_sort}{entry_date format="%Y-%F"}{/stash:date_sort}
		    {stash:date_machine}{entry_date}{/stash:date_machine}
		{/exp:channel:entries}

{/exp:stash:set_list}

@croxton
croxton / Semantic responsive grids with CSS Crush.css
Last active April 8, 2018 01:29
Semantic resposive grids with CSS Crush
/* =============================================================================
Variables
========================================================================== */
@define {
grid-gutter: 30px;
small: min-width:36em;
medium: min-width:48em;
large: min-width:62.5em;
xlarge: min-width:75em;