Skip to content

Instantly share code, notes, and snippets.

View jameswilson's full-sized avatar

James Wilson jameswilson

View GitHub Profile
@jameswilson
jameswilson / _more-link.sass
Created May 23, 2014 16:16
More Link with triangle after
@jameswilson
jameswilson / myfeature.php
Created May 28, 2014 14:53
Clean up Bean edit forms
<?php
/**
* Implements hook_form_ID_alter().
*/
function myfeature_form_bean_form_alter(&$form, &$form_state, $form_id) {
// Simplify the log message field.
if (isset($form['revision'])) {
$form['revision']['log']['#type'] = 'textfield';
@jameswilson
jameswilson / drupal_multilanguage_date_formats.php
Last active August 29, 2015 14:02
Multi-language date formats for Drupal 7
<?php
// Place this in a custom module, eg "mymodule.module"
/**
* Implements hook_date_format_types().
*/
function mymodule_date_format_types() {
return array(
'post_date' => t('Post date'),
);
@jameswilson
jameswilson / drupal_menu_rebuild.php
Created June 16, 2014 21:56
Rebuild a Drupal 7 menu.
<?php
// To clear the Drupal 7 menu structure, temporarily add this file to the root
// of your drupal project and run it from a webbrowser or the command line.
error_reporting(E_ALL);
define('DRUPAL_ROOT', getcwd());
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
menu_rebuild();
// Place this in mymodule.module
/**
* Implements hook_panels_pre_render().
*/
function mymodule_panels_pre_render($panels_display, $renderer) {
// Add a body class for all panel layouts present on a given page. This
// functionality piggy-backs on Panels 'body_classes_to_add' functionality.
// And let's us do clever things like null out the max-width of container
@jameswilson
jameswilson / drupal_check_dead_mods.php
Created July 23, 2014 23:30
Check for Dead Drupal Modules
<?php
// Place script in root directory of Drupal installation.
// From https://www.drupal.org/node/1080330#comment-6520842
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
function nobueno() {
$startingtime = microtime(true);
$o = '<p>Checking for dead modules ...</p>';
$result = db_select('system')
<?php
/**
* @file
* html_in_title.features.filter.inc
*/
/**
* Implements hook_filter_default_formats().
*/
function html_in_title_filter_default_formats() {
@jameswilson
jameswilson / better_bean_classes.php
Created August 7, 2014 21:09
Cleanup bean classes.
<?php
/**
* Implements hook_preprocess_block().
*/
function mymodule_preprocess_entity(&$variables) {
// modify the classes on bean entities.
if ($variables['entity_type'] == 'bean') {
$variables['classes_array'] = array(
drupal_html_class($variables['bean']->type),
@jameswilson
jameswilson / mytheme_template.php
Created August 9, 2014 12:18
Remove duplicate stylesheets for RTL themes that use _directional.scss
<?php
/**
* Implements hook_css_alter().
*/
function mytheme_css_alter(&$css) {
global $language;
// If the current language is RTL, find and remove CSS files from this
// theme that have the RTL overrides. Drupal's RTL methodology adds files
// Animated throbber
html.js .form-autocomplete {
background-image: image-url('svg/throbber-inactive.svg');
background-position: 95% center;
background-position: -webkit-calc(100% - 5px) center;
background-position: calc(100% - 5px) center;
background-repeat: no-repeat;
}
html.js .throbbing {