Skip to content

Instantly share code, notes, and snippets.

View kmgdevelopment's full-sized avatar

Kristen Grote kmgdevelopment

View GitHub Profile
@kmgdevelopment
kmgdevelopment / paypal_donate.html
Created May 18, 2012 16:28
Secure Paypal Donate Button with Custom Amount Field
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="business" value="[Your Secure Merchant ID]" >
<input type="hidden" name="cmd" value="_donations" >
<input type="hidden" name="item_name" value="[Donation Description]" >
<input type="hidden" name="return" value="http://yourdomain.com/thank-you" >
<div>
<label for="amount">Donation Amount:</label>
<input name="amount" type="text" id="amount" >
</div>
<input name="submit" type="submit" value="Donate" >
@kmgdevelopment
kmgdevelopment / stack_trace.txt
Created September 27, 2018 19:42
Stack Trace
yii\base\ErrorException: Illegal offset type in /path/to/plugin/kgrote/siteutilities/src/fields/Regionselect.php:95
Stack trace:
#0 /path/to/site/craft/vendor/craftcms/cms/src/web/ErrorHandler.php(76): yii\base\ErrorHandler->handleError(2, 'Illegal offset ...', '/Users/kristeng...', 95)
#1 /path/to/plugin/kgrote/siteutilities/src/fields/Regionselect.php(95): craft\web\ErrorHandler->handleError(2, 'Illegal offset ...', '/Users/kristeng...', 95, Array)
#2 /path/to/site/craft/vendor/craftcms/cms/src/base/Element.php(1936): loveco\siteutilities\fields\Regionselect->normalizeValue(Array, Object(craft\elements\Entry))
#3 /path/to/site/craft/vendor/craftcms/cms/src/base/Element.php(793): craft\base\Element->normalizeFieldValue('region')
#4 /path/to/site/craft/vendor/yiisoft/yii2/base/ArrayableTrait.php(126): craft\base\Element->__get('region')
#5 /path/to/site/craft/vendor/craftcms/cms/src/web/View.php(504): yii\base\Model->toArray(Array, Array, false)
#6 /path/to/site/craft/vendor/craftcms/cms/src/helpers/ElementHe
<?php
public function normalizeValue($value, ElementInterface $element = null)
{
$opts = $this->setOptions();
$value = array
(
'value' => $value,
'label' => $opts[$value]
@kmgdevelopment
kmgdevelopment / gist:2789080
Created May 25, 2012 16:34
ExpressionEngine Sub-Category Dropdown Menu
<form name="catmenu" action="">
<label for="cat-select">Choose A Category</label>
<select id="cat-select" name="selcat">
<option value="">-- Select --</option>
{exp:channel:categories channel="mychannel" disable="category_fields" style="linear"}
{if parent_id == '0'}
<option value="{path='mychannel'}">{category_name}</option>
{/if}
{if parent_id != '0'}
<option value="{path='mychannel'}" class="subcat">&#8627; {category_name}</option>
<a href="https://vimeo.com/180766765">Watch Video</a>
<div id="video-wrap"></div>
<script>
$('a').on('click', function(e){
e.preventDefault();
var videoUrl = $(this).attr('href');
<a href="https://vimeo.com/181033143">Link!</a>
Becomes:
<a href="http://192.168.1.123:8005/https://vimeo.com/181033143">Link!</a>
@kmgdevelopment
kmgdevelopment / gist:2ea31d2aaceb1265a4f5a486c51da8c2
Created March 30, 2016 04:02
Regex: Split HTML Text Elements
<(p|ul|ol|h1|h2|h3|h4|h5|h6|div|table|blockquote)>[.\S\s]*?<\/(p|ul|ol|h1|h2|h3|h4|h5|h6|div|table|blockquote)>
@kmgdevelopment
kmgdevelopment / craftCategories.twig
Created January 19, 2016 03:23
Craft CMS: Output an Entry's Categories
{# 'groupname' is the shortname of your category group #}
{% for category in entry.groupnameCategories %}
{{ category.title }}
{{ category.slug }}
{% endfor %}
@kmgdevelopment
kmgdevelopment / gist:8460749
Created January 16, 2014 18:39
Exclude Excepted Links from Open-in-New-Window Script
var exceptedLinks = [
'.webinars .banner .share a',
'.someotherlink'
]
$('a').each(function() {
var link = $(this);
excepted = false;
@kmgdevelopment
kmgdevelopment / gist:8447370
Created January 16, 2014 00:11
open all links in new tab
$('a').each(function() {
// get this site's URL
var a = new RegExp('/' + window.location.host + '/');
// check if the link is an actual web link
if(this.href.match(/^http/)){
// check if the link contains this site's URL
if(!a.test(this.href)) {
$(this).click(function(event) {
event.preventDefault();