Skip to content

Instantly share code, notes, and snippets.

Avatar

Patrick Harrington mildlygeeky

View GitHub Profile
View m200829_184642_fix_colous_swatches.php
<?php
namespace craft\contentmigrations;
use Craft;
use craft\db\Migration;
/**
* m200829_184642_fix_colour_swatches migration.
*/
@mildlygeeky
mildlygeeky / CacheBustingCraftValetDriver.php
Created Aug 26, 2017
Valet Driver for Craft CMS (2.x) that tries to resolve filenames using static asset versioning, per https://nystudio107.com/blog/simple-static-asset-versioning
View CacheBustingCraftValetDriver.php
<?php
class CacheBustingCraftValetDriver extends ValetDriver
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
View gist:5abbf8e61bc37c41be87bde9265d6905
### Keybase proof
I hereby claim:
* I am mildlygeeky on github.
* I am mildlygeeky (https://keybase.io/mildlygeeky) on keybase.
* I have a public key ASDegx54rfKDh0lbjQR4XWM2gLQaeLKl9g1hgtKNVbzVPgo
To claim this, I am signing this object:
View _layout.html
<!doctype html>
<html lang="en">
<head>
<!-- Responsive-ness -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- SE-Oh -->
{% include '_includes/seo_meta' %}
</head>
@mildlygeeky
mildlygeeky / Installing Imagick with PHP 7.md
Last active Mar 6, 2016 — forked from mmikkel/Installing Imagick with PHP 7.md
Installing Image Magick for PHP 7 on a Server Pilot managed server
View Installing Imagick with PHP 7.md
apt-get install pkg-config libmagickwand-dev -y
cd ~/downloads
wget https://pecl.php.net/get/imagick-3.4.0.tgz
tar xvzf imagick-3.4.0.tgz
cd imagick-3.4.0
/opt/sp/php7.0/bin/phpize
./configure --with-php-config=/opt/sp/php7.0/bin/php-config
make install
rm -rf /tmp/imagick-3.4.0*
View Basic Picturefill
{% if entry.homepageHeroDesktop|length > 0 and entry.homepageHeroMobile|length > 0 %}
<div class="homepage-hero homepage-hero--image">
<figure>
<picture>
{% set homepageHeroDesktop = entry.homepageHeroDesktop.first().getUrl() %}
{% set homepageHeroMobile = entry.homepageHeroMobile.first().getUrl() %}
<!--[if IE 9]><video style="display: none;"><![endif]-->
<source srcset="{{ homepageHeroDesktop }}" media="(min-width: 540px)">
@mildlygeeky
mildlygeeky / gist:6f8eeb28a10240cde5a0
Last active Aug 29, 2015
Generating a menu for Matrix blocks in Craft CMS
View gist:6f8eeb28a10240cde5a0
{% for block in entry.bodyBlocks %}
{%- if loop.first %}<ul>{% endif %}
<li><a href="#bodyblock-{{ block.ownerId }}-{{ block.id }}">{{ block.blockName }}</a></li>
{%- if loop.first %}</ul>{% endif %}
{%- endfor %}
@mildlygeeky
mildlygeeky / gist:14b814ec8c815a1f5c6f
Last active Jan 3, 2019
Dynamic Navigation using native Craft CMS and Twig templates
View gist:14b814ec8c815a1f5c6f
{# For this, I wanted the nav to show the top-level node and second-level nodes #}
{# when on level 1, and then show the second-level and its children when on #}
{# level 2 or level 3 (so we get good parent, child, and sibling navigation. #}
{# Requires string 'sectionName' to be passed with Structure section name #}
{% if entry.showLeftNavigation %}
<nav class="interior-page__nav">
@mildlygeeky
mildlygeeky / gist:4547577
Created Jan 16, 2013
Print Stylesheet code
View gist:4547577
/* ==========================================================================
Print styles.
Inlined to avoid required HTTP connection: h5bp.com/r
========================================================================== */
@media print {
* {
background: transparent !important;
color: #000 !important; /* Black prints faster: h5bp.com/s */
box-shadow: none !important;