Skip to content

Instantly share code, notes, and snippets.

@waako
waako / break-email-address.js
Created August 18, 2011 06:06
add break before @ symbol if email address is longer than n characters
/* Add a line break before the @ in email addresses if longer than n characters to help legibility and prevent widows */
jQuery('.contact-information-box a.email:contains("@")').each(function() {
var getContent=$(this).text();
if( $(this).text().length > 31) {
var newString=getContent.replace('@','<br />@');
}
jQuery(this).html(newString);
});
@waako
waako / template.php
Created February 3, 2012 18:15
Drupal, get theme path in javascript
<?php
function theme_preprocess_page(&$variables) {
drupal_add_js('jQuery.extend(Drupal.settings, { "pathToTheme": "' . path_to_theme() . '" });', 'inline');
}
?>
@waako
waako / last value.html
Created February 21, 2012 08:43
Get value of last nested li and output in element of same parent
<!-- Trying to print title value of :last li.nested.one in the closest div.header -->
<ul>
<li class="parent">
<div class="header"></div>
<ul>
<li class="nested one">
<li class="nested one">
<li class="nested one" title="first">
<li class="nested two">
@waako
waako / .gitignore
Created July 31, 2012 13:59
Drupal, SASS and ST2 gitignore file
# Ignore configuration files that may contain sensitive information.
sites/*/settings*.php
sites/sites.php
# Ignore paths that contain user-generated content.
sites/*/files
sites/*/private
# Ignore Sublime Text 2 local project files
*.sublime-project
<?php
/**
* Implements hook_form_alter().
To Replace the -Any- value in filters by it's label text
*/
function theme_form_alter(&$form, &$form_state, $form_id) {
kpr($form);
if ($form['#id'] == 'views-exposed-form-admin-people-block-1') {
// $my_label = 'label name';
<?php
/**
* Implements hook_form_alter().
To Replace the -Any- value in filters by it's label text
*/
function theme_form_alter(&$form, &$form_state, $form_id) {
kpr($form);
if ($form['#id'] == 'views-exposed-form-admin-people-block-1') {
// $my_label = 'label name';
<?php
/**
* Implements hook_form_alter().
To Replace the -Any- value in filters by it's label text
*/
function mp_form_alter(&$form, &$form_state, $form_id) {
kpr($form);
if ($form['#id'] == 'views-exposed-form-admin-people-block-1') {
// $my_label = 'label name';
@waako
waako / gist:4040102
Created November 8, 2012 17:04
Output all field values into a single unordered list
// Prepare a renderable array to hold items.
$variables['planning'] = array(
'#theme' => 'item_list',
'#items' => array(),
);
// Add the term as a new renderable item in the list.
foreach(($variables['field_planning'] + $variables['field_diet'] + $variables['field_healthy']) as $taxon_term_field) {
$term_name = $taxon_term_field['taxonomy_term']->name;
$variables['planning']['#items'][] = $term_name;
@waako
waako / merge item_list items.php
Created November 29, 2012 16:29
merge two items to be rendered in item_list
$variables['planning'] = array(
'#theme' => 'item_list',
'#items' => array(),
'#attributes' => array(
'class' => 'icons-info unstyled floated',
)
);
foreach(array_merge($variables['field_bbcgf_planning'], $variables['field_bbcgf_diet'], $variables['field_bbcgf_healthy']) as $taxon_term_field) {
$term_name = $taxon_term_field['taxonomy_term']->name;
@waako
waako / merge item_list items.php
Created November 29, 2012 18:21 — forked from rupertj/merge item_list items.php
merge two items to be rendered in item_list
$variables['planning'] = array(
'#theme' => 'item_list',
'#items' => array(),
'#attributes' => array(
'class' => 'icons-info unstyled floated',
)
);
$all_terms = array_merge($variables['field_bbcgf_planning'], $variables['field_bbcgf_diet'], $variables['field_bbcgf_healthy']);