Skip to content

Instantly share code, notes, and snippets.

@jamiepittock
jamiepittock / CollapseSidebarAsset.php
Created February 21, 2024 08:50 — forked from wsydney76/CollapseSidebarAsset.php
Make sections of Craft 5 element indexes collapsible
<?php
namespace modules\main\web\assets\collapsesidebar;
use craft\web\AssetBundle;
/**
* Collapse Sidebar asset bundle
* Experimental!
*
@jamiepittock
jamiepittock / fullNameToFirstName.php
Created November 24, 2022 10:46 — forked from stilliard/fullNameToFirstName.php
PHP - Get a users first name from the full name
<?php
/**
* Get a users first name from the full name
* or return the full name if first name cannot be found
* e.g.
* James Smith -> James
* James C. Smith -> James
* Mr James Smith -> James
* Mr Smith -> Mr Smith
<?php
// Stripped down for brevity
class BPlugin {
public function init () {
// Trigger Google Shopping updates
// =====================================================================
if (!craft()->config->get('devMode')) {
@jamiepittock
jamiepittock / craftblockwrap.twig
Created February 2, 2018 21:58 — forked from Chrisedmo/craftblockwrap.twig
Craft CMS matrix blocks intelligent wrapping
{# _partials/blocks/blocks.html #}
{#
Blocks component
Outputs a matrix field blocks, intelligently wrapping blocks that need to be inset from the edges
@param {object} contentBlocks (MatrixBlockModel)
#}
{# Parameters #}
@jamiepittock
jamiepittock / gist:9749399
Last active August 29, 2015 13:57
Better Meta overrides
// Global template
{exp:nsm_better_meta:template}
// Page template
{embed="_embeds/start"
entry_id="{entry_id}"
description="Bar"
}
@jamiepittock
jamiepittock / gist:8579243
Last active January 4, 2016 05:59
Unique venues
{exp:stash:set_list name="venues" parse_tags="yes" parse_conditionals="yes" trim="yes"}
{exp:channel:entries channel="events" dynamic="no" show_future_entries="yes"}
{if cf_events_place}
{stash:venue_title}{cf_events_place}{title}{/cf_events_place}{/stash:venue_title}
{stash:venue_id}{cf_events_place}{entry_id}{/cf_events_place}{/stash:venue_id}
{/if}
{/exp:channel:entries}
{/exp:stash:set_list}
<select>
/* The Grid ---------------------- */
.lt-ie9 .row { width: 940px; max-width: 100%; min-width: 768px; margin: 0 auto; }
.lt-ie9 .row .row { width: auto; max-width: none; min-width: 0; margin: 0 -15px; }
.lt-ie9 .row.large-collapse .column,
.lt-ie9 .row.large-collapse .columns { padding: 0; }
.lt-ie9 .row .row { width: auto; max-width: none; min-width: 0; margin: 0 -15px; }
.lt-ie9 .row .row.large-collapse { margin: 0; }
.lt-ie9 .column, .columns { float: left; min-height: 1px; padding: 0 15px; position: relative; }
.lt-ie9 .column.large-centered, .columns.large-centered { float: none; margin: 0 auto; }
@jamiepittock
jamiepittock / ExpressionEngine template
Created November 23, 2012 11:48
Inject events from low_events:entries into low_events:calendar cells
{exp:low_events:calendar
events_field="cf_events_date_time"
date="{freebie_4}"
}
<table class="calendar" cellspacing="0" cellpadding="0">
<thead>
<tr id="month_pager">
<th colspan="1" class="previous"><a href="{structure:page:uri}
on/{prev_month_url}" title="{prev_month format='%F %Y'}">&larr;</a></th>
<th colspan="5" class="month_title"><a href="{structure:page:uri}
SELECT ct.entry_id, ct.title, ct.url_title, cd.field_id_344 as cf_places_latitude, cd.field_id_345 as cf_places_longitude, ROUND( '3959' * acos( cos( radians('51.494737') ) * cos( radians( cd.field_id_344 ) ) * cos( radians( cd.field_id_345 ) - radians('-0.146358') ) + sin( radians('51.494737') ) * sin( radians( cd.field_id_344 ) ) ), '2' ) AS distance
FROM exp_channel_data as cd
LEFT JOIN exp_channel_titles as ct ON ct.entry_id = cd.entry_id
WHERE ct.channel_id IN ('2')
AND ct.entry_id != '12'
HAVING distance < '1'
ORDER BY distance desc
// Hidden form on checkout page
<div style="display: none">
{exp:cartthrob:save_customer_info_form
return=""
id="customer_form"
}
<input type="hidden" name="country_code" id="hidden_country" value="" />
{/exp:cartthrob:save_customer_info_form}
</div>