Skip to content

Instantly share code, notes, and snippets.

@Greg-Boggs
Greg-Boggs / purge_cf.php
Last active August 7, 2023 09:23
PHP code to Purge Cloudflare Cache
<?php
// Replace EMAIL/API_KEY/ZONE_ID with your details.
// Zone ID is on the dashboard for the domain in the bottom right.
// Api keys are generated from the account settings. You must give cache purge permissions
// Place this script on your webserver and point a Github Webhook at it, and you'll clear
// the Cloudflare cache every time you do a push to GH.
$zoneId = "xxx";
$apiKey = "xxx";
$email = "xxx";

Hi First_Name,

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt exercitation ullamco est laborum.

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

~G

@Greg-Boggs
Greg-Boggs / nav.php
Last active July 24, 2019 22:54
Nav component
<nav class="navbar navbar-default">
<!-- toggle -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
@Greg-Boggs
Greg-Boggs / breadcrumb-cache-example.php
Last active July 24, 2019 22:45
Expire the cache for Breadcrumbs when the page changes in Drupal 8
<?php
// Expire the cache per url.
$breadcrumb->addCacheContexts(['url.path']);
// Expire cache context for config changes.
$breadcrumb->addCacheableDependency($this->config);
// Handle views path expiration cache expiration.
$parameters = $route_match->getParameters();
foreach ($parameters as $key => $parameter) {
@Greg-Boggs
Greg-Boggs / EasyBreadcrumb.html
Last active May 8, 2019 00:49
Easy Breadcrumb Release notes for 1.9
Release notes below.
@Greg-Boggs
Greg-Boggs / events.js
Last active September 10, 2020 14:30
Event tracking example with Google universal analytics
jQuery(document).ready(function ($) {
// Track all link clicks internal and external
$('a').click(function(e) {
var linkUrl = e.target.href;
var linkText = $(this).text();
if (this.hostname && this.hostname !== location.hostname) {
ga('send', 'event', {
eventCategory: 'Outbound Link',
@Greg-Boggs
Greg-Boggs / events.js
Last active April 6, 2020 16:18
data layer tracking example
jQuery(document).ready(function ($) {
// Track all link clicks internal and external
$('a').click(function(e) {
var linkUrl = e.target.href;
var linkText = $(this).text();
if (this.hostname && this.hostname !== location.hostname) {
dataLayer.push({
'event' : 'gaEvent',
@Greg-Boggs
Greg-Boggs / functions.php
Created April 12, 2018 01:59
Get the title of any page in Drupal 8
<?php
$title = $this->titleResolver->getTitle($route_request, $route_match->getRouteObject());
// Many paths return a translatable markup object.
if ($title instanceof TranslatableMarkup) {
// Sets the title to the translated string.
$title = $title->render();
}
@Greg-Boggs
Greg-Boggs / functions.php
Last active April 7, 2018 19:56
Helper function to get renderable region for Drupal 8
<?php
// Example usage: $build = blocks_get_blocks_by_region('sidebar_first');
function blocks_get_blocks_by_region($region_name) {
$build = [];
$blocks = entity_load_multiple_by_properties('block', ['theme' => $GLOBALS['theme'], 'region' => $region_name]);
uasort($blocks, 'Drupal\block\Entity\Block::sort');
foreach ($blocks as $key => $block) {
@Greg-Boggs
Greg-Boggs / gist:f3e3429c07fc59b8a44d3a6a48728ae6
Created November 7, 2017 19:20
Drupal User Group Outline
Tell the folks who you are and welcome them to portland DUG
Give them this list in a breif overview of what they can expect. Let them know about the after group hangout at Pints.
Show them Groups.Drupal and encourage them to sign up for email updates by joining the group.
Get folks into IRC/Slack.
Call for organizers for next year.
Call for Speaker for next month.
Thank the sponsor.
Promote brewpal.
Announcements (PNW).
Ice breaker question.