Skip to content

Instantly share code, notes, and snippets.

View micahredding's full-sized avatar

Micah Redding micahredding

View GitHub Profile
@micahredding
micahredding / gist:6599093
Last active December 23, 2015 07:09
A php loop
foreach($form['edit_delete'] as $index => $contents) {
if(is_numeric($index) && is_array($contents)) {
$form['edit_delete'][$index]['#value'] = 'X';
}
}
<?php
/* @begin - Blocks */
function liveschool_block_info() {
$blocks = array();
$blocks['any_device'] = array(
'info' => t('Any Device, Anywhere.'),
'cache' => DRUPAL_NO_CACHE,
);
function qhr_menu_block_tweaks_menu_block_tree_alter(&$tree, &$config) {
foreach ($tree as $key => $item) {
if (isset($item['below'])) {
foreach($item['below'] as $id => $below) {
if (isset($below['link']['link_path']) && $below['link']['link_path'] === '<view>') {
$below['link']['hidden'] = true;
$tree[$key]['below'][$id] = $below;
}
}
}
function qhr_menu_block_tweaks_menu_block_tree_alter(&$tree, &$config) {
foreach ($tree as $key => $item) {
if (isset($item['below'])) {
foreach($item['below'] as $id => $below) {
if (isset($below['link']['link_path']) && $below['link']['link_path'] === '<view>') {
$below['link']['hidden'] = true;
$tree[$key]['below'][$id] = $below;
}
}
}
@micahredding
micahredding / css
Created June 6, 2013 20:08
output of bourbon neat omega mixin
.fluid-grid-2 {
list-style: none;
padding-left: 0;
*zoom: 1;
max-width: 58.75em;
margin-left: auto;
margin-right: auto; }
.fluid-grid-2:before, .fluid-grid-2:after {
content: " ";
display: table; }
@micahredding
micahredding / gist:5555012
Last active December 17, 2015 04:59
custom tooltip (adapted from evan)
<script>
$('.tooltip').children('.tooltip-tooltip').append('<span class="tooltip-pointer"></span>');
$('.tooltip').hoverIntent(function() {
var body = $(this).children('.tooltip-tooltip');
bodyHeight = -(body.height() - 20);
bodyWidth = -(body.width() / 2);
body.css('top', bodyHeight);
body.css('left', bodyWidth);
body.show();
}, function() {
@micahredding
micahredding / convert mysql from innodb to myisam
Created April 1, 2013 20:19
alter table cache engine = myisam; alter table cache_admin_menu engine = myisam; alter table cache_block engine = myisam; alter table cache_bootstrap engine = myisam; alter table cache_field engine = myisam; alter table cache_file_styles engine = myisam; alter table cache_filter engine = myisam; alter table cache_form engine = myisam; alter tabl…
convert mysql from innodb to myisam
@micahredding
micahredding / gist:5197132
Created March 19, 2013 15:38
How to upload a file in a block configure form
function hook_block_configure($delta = '') {
$form['image'] = array(
'#title' => t('Image'),
'#type' => 'managed_file',
'#description' => t('The uploaded image will be displayed on this page using the image style choosen below.'),
'#upload_location' => 'public://header_blocks/',
);
}
@micahredding
micahredding / gist:5153630
Last active December 14, 2015 21:49
get current product
global $user;
$cart = commerce_cart_order_load($user->uid);
if($cart) {
$line = commerce_line_item_load($cart->commerce_line_items['und'][0]['line_item_id']);
$product = commerce_product_load($line->commerce_product['und'][0]['product_id']);
$sku = $product->sku;
dpm($sku);
}
@micahredding
micahredding / gist:5092638
Created March 5, 2013 18:11
how to switch jquery versions ONLY for the frontside theme
/* Unset jquery, add back in the upgraded version, compatible with Bootstrap */
/* since this happens at the theme level, Drupal's admin theme can use the old version */
function THEMENAME_js_alter(&$javascript) {
unset($javascript['misc/jquery.js']);
}
function THEMENAME_preprocess_page(&$variables,$hook) {
/* Unset jquery, add back in the upgraded version, compatible with Bootstrap */
/* since this happens at the theme level, Drupal's admin theme can use the old version */
drupal_add_js(drupal_get_path('theme', 'THEMENAME') . '/assets/js/vendor/jquery/1.7/jquery.min.js', array('group' => -200, 'weight' => -100));