Skip to content

Instantly share code, notes, and snippets.

View joshuapowell's full-sized avatar
☄️
https://info.cern.ch/hypertext/

J.I. Powell joshuapowell

☄️
https://info.cern.ch/hypertext/
View GitHub Profile
@joshuapowell
joshuapowell / messages.less
Created January 26, 2012 02:22
LESS: LESS CSS basic console and messages (e.g., error, warning, status) to work with Drupal's HTML class attributes
/**
* Messages
*
*
*/
#console {
border: 0;
font-size: 12px;
margin: 14px 0 0;
.messages {
@joshuapowell
joshuapowell / reset.less
Last active September 25, 2024 18:58
LESS: Global LESS CSS reset that gives elements default formatting.
/**
* Global Reset of all HTML Elements
*
* Resetting all of our HTML Elements ensures a smoother
* visual transition between browsers. If you don't believe me,
* try temporarily commenting out this block of code, then go
* and look at Mozilla versus Safari, both good browsers with
* a good implementation of CSS. The thing is, all browser CSS
* defaults are different and at the end of the day if visual
* consistency is what we're shooting for, then we need to
@joshuapowell
joshuapowell / template.php
Created January 26, 2012 02:17
Drupal: Automatically clear all site caches and reset all Views (i.e., views that are coded and saved as individual files)
<?php
/**
* Automated Cache Clearing
*
* For development purpose only, this cannot be enabled on a live
* website or else it will make everyone that uses the site sad.
*/
/* Clear all Drupal core caches */
@joshuapowell
joshuapowell / preprocess.inc
Created January 26, 2012 02:16
Drupal: Allow for Node Type specific page.tpl.php files (e.g., page--node--story.tpl.php, page--node--page.tpl.php, page--node--webform.tpl.php)
<?php
/**
* Implementation of hook_preprocess_page().
*/
function MYTHEME_preprocess_page(&$variables, $hook) {
// Allow for page templates, based on node type
if (isset($variables['node'])) {
$variables['theme_hook_suggestions'][] = 'page__node__' . str_replace('_', '--', $variables['node']->type);
@joshuapowell
joshuapowell / preprocess.inc
Created January 26, 2012 02:14
Drupal: Allow for Node Type specific html.tpl.php files (e.g., html--story.tpl.php, html--page.tpl.php, html--webform.tpl.php)
<?php
/**
* Implementation of hook_preprocess_html().
*/
function MYTHEME_preprocess_html(&$variables, $hook) {
if ($node = menu_get_object()) {
if (isset($node->type)) {
$variables['theme_hook_suggestions'][] = 'html__' . str_replace('_', '--', $node->type);
@joshuapowell
joshuapowell / preprocess.inc
Created January 26, 2012 02:13
Drupal: Remove as much pre-generated core CSS as possible
<?php
/**
* Implementation of hook_css_alter().
*/
function MYTHEME_css_alter(&$css) {
// Remove core block stylesheet(s)
unset($css[drupal_get_path('module', 'block') . '/block.css']);
@joshuapowell
joshuapowell / theme.inc
Created January 26, 2012 02:11
Drupal: Wrap all menu elements with an HTML <nav> tag
<?php
/**
* Implementation of theme_menu_tree().
*/
function MYTHEME_menu_tree(&$variables) {
return '<nav><ul class="menu">' . $variables['tree'] . '</ul></nav>';
}
@joshuapowell
joshuapowell / hooks.inc
Created January 26, 2012 02:10
Drupal: Update the meta elements in the <head> of the template that are generated dynamically. In this case we are setting the charset according to HTML5 standards and removing the generator meta tag, RSS meta tag, the default FAVICON, and the default sho
<?php
/**
* Implementation of hook_html_head_alter().
*/
function THEMENAME_html_head_alter(&$head_elements) {
// Update the charset to use HTML5 format
$head_elements['system_meta_content_type'] = array(
'#type' => 'html_tag',
@joshuapowell
joshuapowell / gist:1478159
Created December 14, 2011 19:49
JustinTV JSON Caching
<?php
/**
* Class SM
*
* Define a generic wrapper class with some system
* wide functionality. In this case we'll give it
* the ability to fetch a social media feed from
* another server for parsing and possibly caching.
*
@joshuapowell
joshuapowell / MYMODULE.info
Created November 25, 2011 23:08
Drupal 7 & Views 3 capable dynamically loading views
name = "MY MODULE"
description = "Custom Views specific to a website"
package = "MY WEBSITE"
core = 7.x
dependencies[] = views