Skip to content

Instantly share code, notes, and snippets.

View Riaan-ZA's full-sized avatar

Riaan Riaan-ZA

View GitHub Profile
@Riaan-ZA
Riaan-ZA / gist:2049293
Created March 16, 2012 09:34
CSS: Image Replacement
.ir {
border: 0;
font: 0/0 a;
text-shadow: none;
color: transparent;
background-color: transparent;
}
@Riaan-ZA
Riaan-ZA / gist:2111393
Created March 19, 2012 13:05
Drupal 7: Test if field has a value
<?php if (field_get_items('node', $node, 'field_address')) : ?>
<?php endif; ?>
@Riaan-ZA
Riaan-ZA / gist:2111438
Created March 19, 2012 13:06
Drupal 7: Access fields raw value
<?php print $field_email[0]['value']; ?>
@Riaan-ZA
Riaan-ZA / gist:2725094
Created May 18, 2012 12:50
Drupal 7: Breadcrumbs in ul
if (!empty($breadcrumb)) {
$crumbs = '<ul class="breadcrumb">';
$lastItem = count($breadcrumb) - 1;
foreach($breadcrumb as $index=>$value) {
if ($index == $lastItem) {
$crumbs .= '<li class="breadcrumb-last">'.t($value).'</li>';
}
else {
$crumbs .= '<li>'.t($value).'</li>';
@Riaan-ZA
Riaan-ZA / gist:2768157
Created May 22, 2012 10:17
Facebook - URL to add app as tab
https://www.facebook.com/dialog/pagetab?app_id=YOUR_APP_ID&next=YOUR_URL
@Riaan-ZA
Riaan-ZA / gist:2843799
Created May 31, 2012 14:34
Drupal 7: Remove seperator between panels
function oilcouncil_panels_default_style_render_region($vars) {
$output = '';
$output .= implode('', $vars['panes']);
return $output;
}
@Riaan-ZA
Riaan-ZA / gist:2875346
Created June 5, 2012 14:28
Drupal 7: Add <div> around sub menu
function oilcouncil_menu_link(array $variables) {
$element = $variables['element'];
$sub_menu = '';
if ($element['#below']) {
$sub_menu = "<div>".drupal_render($element['#below'])."</div>";
}
$output = l($element['#title'], $element['#href'], $element['#localized_options']);
return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}
@Riaan-ZA
Riaan-ZA / gist:2887922
Created June 7, 2012 09:53
Drupal 7: Breadcumbs with image sperator
function oilcouncil_breadcrumb($variables) {
$breadcrumb = $variables['breadcrumb'];
if (!empty($breadcrumb)) {
return '<div class="breadcrumb">'. implode('<img src="' . base_path() . path_to_theme() . '/images/img_breadcrumb_sep.gif" />', $breadcrumb) .'</div>';
}
}
@Riaan-ZA
Riaan-ZA / gist:2929181
Created June 14, 2012 09:01
Facebook: Create Tab URL
https://www.facebook.com/dialog/pagetab?app_id=YOUR_APP_ID&next=YOUR_URL
@Riaan-ZA
Riaan-ZA / gist:2952824
Created June 19, 2012 07:37
PHP Contact Form
<?php
//Validation
$error = "";
//Source Name
if ($name == "" or $name == "Name") {
$error = "<li>Please enter your name</li>";
}
if ($surname == "" or $surname == "Surname") {
$error .= "<li>Please enter your surname</li>";
}