Skip to content

Instantly share code, notes, and snippets.

View ewillhite's full-sized avatar

Evan Willhite ewillhite

View GitHub Profile
<?php
// General Node Preprocess
function wyckwyre_preprocess_node(&$variables) {
$node = $variables['node'];
// Project Node
if ($node->type == 'product') {
$fid = $node->field_section['und'][0]['value'];
$section = field_collection_item_load($fid);
@ewillhite
ewillhite / gist:6700731
Last active December 23, 2015 22:08
SASS mixin for ol' IE
@mixin desk {
@include media($desk) {
@content;
}
.old-ie & {
@content;
}
}
#logo {
@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
@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');
}
}
}
<?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: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 -->
@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 / 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: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 / 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
}