Skip to content

Instantly share code, notes, and snippets.

View carwin's full-sized avatar
🍔
cheeseburger

Carwin Young carwin

🍔
cheeseburger
  • Missouri
View GitHub Profile
@carwin
carwin / Article-Node-Content.html
Created December 4, 2012 01:31 — forked from jponch-zz/Article-Node-Content.html
Sample markup for article node content
<header class="article-heading">
<div class="meta">
<span class="author">by <a href="" class="name" rel="author">Jeff Eaton</a></span><span class="date">on June 20, 2012</span> <a href="" class="short-url">Short URL</a>
</div><!-- /.meta -->
<hgroup>
<h1>Module Monday: Custom Permissions</h1>
<h2 class="subtitle">Fancy subtitle shows right here just like this when there is one.</h2>
</hgroup>
<ul class="social">
<li><a href="" class="comments">3 Comments</a></li>
@carwin
carwin / resources.md
Created November 10, 2012 19:35
DrupalCamp Chicago - Resources
@carwin
carwin / form-placeholders.js
Created October 30, 2012 03:33
Drupal 7: HTML5 placeholder attributes for form items with typical jQuery fallback for older browsers.
(function ($) {
Drupal.behaviors.yourTheme = {
attach: function(context, settings) {
$('form label').css('display', 'none');
if(Modernizr.input.placeholder) {
// Text inputs
var formElements = $('form').find('input, textarea');
$.each(formElements, function(index, value){
if($(this).is('input')){
var label = $(this).siblings('label').text();
@carwin
carwin / d7_conditional_column_templates.tpl.php
Created September 21, 2012 03:02
Drupal 7: Conditionally change templates based on fields filled out on node creation.
function themefoo_preprocess_node(&$variables, $hook) {
$node = $variables['node'];
$type = $variables['type'];
$columns = 1; // Default to 1 column layout.
/*
* Programmatically figure out how many columns we have
* based on which fields the user has filled out in
* the node form.
*
* I'll update this gist later to explain
@carwin
carwin / drupal_lighttpd_conf
Created September 19, 2012 16:47
Lighttpd Configuration for Drupal
##
## Variables
##
var.log_root = "/var/log/lighttpd"
var.server_root = "/var/www"
var.state_dir = "/var/run"
var.home_dir = "/var/lib/lighttpd"
var.conf_dir = "/etc/lighttpd"
var.vhosts_dir = server_root + "/vhosts"
@carwin
carwin / node.tpl.php
Created September 14, 2012 11:55
Drupal 7: Remove the link on a user-picture entirely and render a region in node.tpl.php
/*
* Render the new user picture
*/
<?php print '<div class="user-picture"><img src="' . $user_picture . '" /></div>'; ?>
/*
* Render the now-available 'below_content' region
* under the content or wherever you want.
*/
<div class="content"<?php print $content_attributes; ?>>
@carwin
carwin / d7_html5_menus.php
Created September 13, 2012 17:26
Drupal 7: Change structure of all menus from pattern [ ul > li > a ] to a valid html5 pattern [ nav > a ]
<?php
/*
* Replace all menu tree <ul> elements with <nav>.
*/
function foo_menu_tree(&$variables) {
return '<nav>' . $variables['tree'] . '</nav>';
}
/*
* Removes <li> from all menu links, leaving only <a>s.
*/
@carwin
carwin / d7_theme_jquery_usage.js
Created September 12, 2012 17:43
Drupal 7: Proper implementation of jQuery in a Drupal theme.
(function ($) {
Drupal.behaviors.themename = {
attach: function(context, settings) {
// Add a hover class to nav items.
$('.mainnav nav a')
.hover(
function() {
$(this).addClass('hover');
},
function() {
@carwin
carwin / icons
Created September 8, 2012 09:28
A list of neat characters I don't want to forget about.
☎ - &#9742; &#x260e;
☂ - &#9730; &#x2602;
☑ - &#9745; &#x2611;
☒ - &#9746; &#x2612;
☐ - &#9744; &#x2610;
☁ - &#9729; &#x2601;
⌘ - &#8984; &#x2318;
♻ - &#9851; &#x267b;
@carwin
carwin / d7_uc_extra_checkout_pane.php
Created September 7, 2012 17:37
Drupal 7: (UNTESTED) Add an extra pane to Ubercart's checkout form / review.
<?php
function yourmodule_custom_form($form, &$form_state, $term) {
/* Note: rather than passing a $term var, you could use arg(2) from the url */
drupal_set_title('Your Label: ' . ucwords($term));
// or
drupal_set_title('Your Label: ' . str_replace('%20',' ', arg(2)));
/* Make life easier: */
$school = ucwords($term);