Skip to content

Instantly share code, notes, and snippets.

@heyMP
heyMP / sh_member_signup.module
Created July 9, 2014 02:33
Replace taxonomy term reference options with images in Drupal
/**
* Implements hook_form_FORM_ID_alter() for premium_plus_order_entityform_edit_form().
*
* Replace the options with images from the taxonomy term
*/
function sh_member_signup_form_premium_plus_order_entityform_edit_form_alter(&$form, &$form_state, $form_id) {
foreach ($form as $formitem_name => $formitem) {
if (isset($formitem['#attributes']['class']) && in_array('field-type-taxonomy-term-reference', $formitem['#attributes']['class'])) {
foreach ($formitem['und']['#options'] as $tid => $option) {
$term = taxonomy_term_load($tid);
@heyMP
heyMP / gist:d49c9daa493e05497823
Last active August 29, 2015 14:03
Drupal Kickstart Front-end tools
##Vagrant Front-end Stack Setup
1. Install Curl
1. sudo apt-get install curl
2. Install RVM
1. \curl -sSL https://get.rvm.io | bash -s stable --ruby
2. source /home/vagrant/.rvm/scripts/rvm
4. rvm requirements
@heyMP
heyMP / gist:f2e7827e6e3c9afb5c7b
Created July 10, 2014 16:10
Sublime Control Settings User
{
"installed_packages":
[
"AdvancedNewFile",
"Auto Semi-Colon",
"BracketHighlighter",
"ColorPick",
"Compass",
"DocBlockr",
"Drupal Snippets",
@heyMP
heyMP / kickstart_custom.info
Created July 10, 2014 21:26
Kickstart Custom module
name = Kickstart Custom
description = "This module contains some cool examples of the Drupal API"
package = Drupal Kickstart
core = 7.x
@heyMP
heyMP / _mixins.scss
Created July 14, 2014 03:08
Kickstart Custom Breakpoints
@mixin respond-to($breakpoint) {
@media only screen and (min-width: $breakpoint) { @content; }
}
@heyMP
heyMP / node--article.tpl.php
Created July 14, 2014 03:10
Kickstart use template.php to set classes
<article id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>
<?php print render($title_prefix); ?>
<?php if (!$page): ?>
<?php if (!$page): ?>
<h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
<?php endif; ?>
<?php endif; ?>
<?php print render($title_suffix); ?>
<?php if ($display_submitted): ?>
@heyMP
heyMP / gist:427e0dc224719b6c2632
Created July 17, 2014 15:16
Drupal Camp Session View
$view = new view();
$view->name = 'schedule';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Schedule';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
@heyMP
heyMP / maillog.mail.inc
Created August 5, 2014 15:47
Extending a class
/**
* An interface for pluggable mail back-ends.
*/
class MaillogMailSystem implements MailSystemInterface {
/**
* Format a message composed by drupal_mail() prior sending.
*
* @param $message
* A message array, as described in hook_mail_alter().
*
@heyMP
heyMP / gist:6beaebed34b08c71d6c5
Created August 11, 2014 03:26
Get the first value of an array
$array = array(0 => 'one', 1 => 'two', 2 => 'three');
$values = array_values($array);
$first_value = array_shift($values);
print $first_value;
// prints 'one'
@heyMP
heyMP / gist:35c22245b12e16a6c7b9
Created August 14, 2014 17:42
Pull Production to Local Dev
#!/bin/bash
read -p "Pulling Current Prod down to IT News Local. Are you sure? " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo "Current Prod down to IT News Local"
drush @itnews.local sql-drop -y
drush sql-sync @current.prod @itnews.local -y
drush @itnews.local vset --yes file_temporary_path "sites/default/files/tmp"
drush @itnews.local dis securepages -y