Skip to content

Instantly share code, notes, and snippets.

View micahredding's full-sized avatar

Micah Redding micahredding

View GitHub Profile
@micahredding
micahredding / template.php
Last active December 30, 2015 00:49
A simple hook_form_alter
function urgentteam_form_alter(&$form, &$form_state, $form_id) {
if($form_id == 'views_exposed_form' && $form['#id'] == 'REPLACE THIS') {
dpm($form);
}
}
@micahredding
micahredding / test.go
Created December 1, 2013 17:08
Go Function to Return MacOS X created time (birthtime)
package main
import (
"fmt"
"log"
"os"
"syscall"
"time"
)
@micahredding
micahredding / gist:7533931
Created November 18, 2013 19:34
Add a page content type template suggestion
if (isset($vars['node'])) {
$vars['theme_hook_suggestions'][] = 'page__' . $vars['node']->type;
<?php
function states_submit($form, &$form_state) {
$i = 0;
while(isset($form_state['values']['states_' . $i])) {
variable_set('state_' . $i, $form_state['values']['states_' . $i]);
$i++;
}
}
# IF THE BROWSER IS INTERNET EXPLORER 10
ieten = (navigator.appVersion.indexOf("MSIE 10") != -1)
if(ieten)
$('html').addClass('ie10')
Starting Drupal installation. This takes a few seconds ... [ok]
WD php: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'developer' for key 'name': INSERT INTO {role} (name, weight) VALUES [error]
(:db_insert_placeholder_0, :db_insert_placeholder_1); Array
(
[:db_insert_placeholder_0] => developer
[:db_insert_placeholder_1] => 2
)
in drupal_write_record() (line 7166 of /Users/micah/Sites/SITENAME/includes/common.inc).
WD php: Warning: Cannot modify header information - headers already sent by (output started at /usr/local/Cellar/drush/5.9/libexec/includes/output.inc:37) in drupal_send_headers() [warning]
(line 1216 of /Users/micah/Sites/SITENAME/includes/bootstrap.inc).
@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;
}
}
}