Skip to content

Instantly share code, notes, and snippets.

View ewillhite's full-sized avatar

Evan Willhite ewillhite

View GitHub Profile
var charts = function () {
// Chart.defaults.global.responsive = true;
var data = {
labels: ["Physical Body", "Emotions & Meaning", "Relationships", "Time", "Work/Career/Mission", "Finances", "Celebrate & Continue"],
datasets: [
{
label: "My First dataset",
fillColor: "rgba(244, 232, 244,0.7)",
strokeColor: "rgba(244, 232, 244,0.7)",
pointColor: "rgba(244, 232, 244,0.7)",
@ewillhite
ewillhite / gist:59fe36744935e157f2e9
Created August 21, 2014 15:28
Form Alter to move Drupal fields
<?php
/**
* Implements hook_form_FORMID_alter().
*/
// Checkout Form Alter
function seedco_form_commerce_checkout_form_checkout_alter(&$form, &$form_state, $form_id) {
// SECTION IN QUESTION
$account_section = $form['account'];
$form['customer_profile_billing']['commerce_customer_address']['und'][0]['account'] = $account_section;
$form['customer_profile_billing']['commerce_customer_address']['und'][0]['account']['#weight'] = -99;
@ewillhite
ewillhite / gist:8960992
Created February 12, 2014 17:58
Drupal 7 Search Block Form Alter
<?php
// Form Alter
function qhr_form_search_block_form_alter(&$form, &$form_state, $form_id) {
$form['search_block_form']['#default_value'] = t('search'); // Set a default value for the textfield
$form['actions']['submit']['#value'] = t('GO!'); // Change the text on the submit button
}
@ewillhite
ewillhite / gist:8581000
Created January 23, 2014 15:53
remove superfish for mobile
# disable superfish on mobile and add mobile interaction
if $("#main-content").css("float") isnt "left"
$(".block-superfish > ul").removeClass("sf-menu").addClass "mobile"
$(".block-superfish li").unbind()
$(".block-superfish > ul > li > a").click ->
$(".block-superfish li").removeClass "sfHover"
$(".block-superfish a").removeClass "sf-clicked"
$(this).addClass("sf-clicked").parent().addClass("sfHover")
$(".block-superfish li ul").removeAttr "style"
@ewillhite
ewillhite / MYMODULE.module
Last active December 30, 2015 04:59
Context Condition (.module file)
<?php
/**
* @file
* Module for defining custom context condition
*/
/**
* Implements hook_context_plugins().
*/
function MYMODULE_context_plugins() {
@ewillhite
ewillhite / gist:7607397
Created November 22, 2013 21:44
ClickTale (right before closing body tag)
<!-- ClickTale Bottom part -->
<script type='text/javascript'>
// The ClickTale Balkan Tracking Code may be programmatically customized using hooks:
//
// function ClickTalePreRecordingHook() { /* place your customized code here */ }
//
// For details about ClickTale hooks, please consult the wiki page http://wiki.clicktale.com/Article/Customizing_code_version_2
@ewillhite
ewillhite / gist:7607379
Created November 22, 2013 21:42
ClickTale (paste right after opening body tag)
<!-- ClickTale Top part -->
<script type="text/javascript">
var WRInitTime=(new Date()).getTime();
</script>
<!-- ClickTale end of Top part -->
<?php
function states_submit($form, &$form_state) {
for($i = 0; $i < 100; $i++) {
if(isset($form_state['values']['states_' . $i])) {
variable_set('state_' . $i, $form_state['values']['states_' . $i]);
}
else {
break;
}
}
@ewillhite
ewillhite / gist:7456993
Created November 13, 2013 21:46
Views Pre-render to add files
<?php
// Views Pre-Render Function
function YOUR_THEME_views_pre_render(&$view) {
if($view->name == 'VIEW_MACHINE_NAME') {
if ($view->current_display == 'VIEW_DISPLAY_MACHINE_NAME') {
drupal_add_js(drupal_get_path('theme', 'YOUR_THEME') .'/js/SPECIFIC_VIEW.js');
}
}
}
@ewillhite
ewillhite / gist:7204127
Created October 28, 2013 20:34
AD MySQL performance
Query
SELECT node.nid AS nid, node.title AS node_title, commerce_product_field_data_field_product_reference.product_id AS commerce_product_field_data_field_product_reference_product_, node.created AS node_created, 'node' AS field_data_field_product_images_node_entity_type, 'node' AS field_data_body_node_entity_type, 'node' AS field_data_field_product_discount_blurb_node_entity_type, 'commerce_product' AS field_data_field_eligible_for_offers_commerce_product_entity
FROM
{node} node
LEFT JOIN {field_data_field_product_reference} field_data_field_product_reference ON node.nid = field_data_field_product_reference.entity_id AND (field_data_field_product_reference.entity_type = 'node' AND field_data_field_product_reference.deleted = '0')
LEFT JOIN {commerce_product} commerce_product_field_data_field_product_reference ON field_data_field_product_reference.field_product_reference_product_id = commerce_product_field_data_field_product_reference.product_id
INNER JOIN {field_data_field_on_sale_now} field_data_field_on