<?php
/**
* Implements hook_menu()
*/
function helper_menu() {
$items = array();
// define the page callback to show the clickable link
$items['shadow-test'] = array(
'title' => t('Shadow Test'),
'page callback' => '_helper_page_callback_shadow_test',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
// define the page callback to process the AJAX request
$items['shadow-test-ajax'] = array(
'title' => t('Shadow Test Ajax'),
'page callback' => '_helper_page_callback_shadow_test_ajax',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
return $items;
}
/**
* Implements the page callback to show the clickable link
*/
function _helper_page_callback_shadow_test() {
// include module css
drupal_add_css(drupal_get_path('module', 'helper') .'/helper.css');
// include module javascript
drupal_add_js(drupal_get_path('module', 'helper') .'/helper.js');
// generate shadow html
$shadow_html = "<div id='shadow' style='background: url(" . '"' . base_path() . drupal_get_path('module', 'helper') .'/shadow.png' . '"' . ")'></div>";
// define javascript variables to be passed to the DOM
$js_vars = array(
'helper' => array(
'ajax_path' => base_path() . 'shadow-test-ajax',
'shadow_html' => $shadow_html,
),
);
// pass variables to javascript
drupal_add_js($js_vars, 'setting');
// create a variable for page output
$output = "";
// create a clickable link
// NOT: this link will be overwritten via jQuery
$output .= l(
t('Click Me'),
$_REQUEST['q'],
array(
'attributes' => array(
'class' => 'ajax_clickable',
),
)
);
// return page output
return $output;
}
/**
* Implements page callback to process the AJAX request
*/
function _helper_page_callback_shadow_test_ajax() {
// wait 2 seconds
// NOTE: this line is just used to demo the "shadow" effect
sleep(3);
// return a JSON value
$ret = new StdClass();
$ret->status = true;
print drupal_json($ret);
die;
}
?>
#shadow {
z-index: 1000;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: none;
}

Drupal.behaviors.helper = function(context) {
// find the link with the matching class, and add a click event
$('.ajax_clickable').click(function(){
// show shadow
$(this).show_shadow();
// make ajax call
$.getJSON(
Drupal.settings.helper.ajax_path,
function(data) {
// when the ajax call is done, hide the shadow
$(this).hide_shadow();
}
);
// prevent the a tag from actually going anywhere
return false;
});
}
;(function($) {
// defines the function to show the shadow
$.fn.show_shadow = function() {
// ensure the shadow does not already exist
if ($('body #shadow').length == 0) {
// add shadow html, and fade it in
$('body').append(Drupal.settings.helper.shadow_html).find('#shadow').fadeIn();
}
}
// defines the function to hide the shadow
$.fn.hide_shadow = function() {
// fade it out, and then remove it from the dom
$('#shadow').fadeOut('slow', function() {
$(this).remove();
});
}
})(jQuery);

<VirtualHost *:80>
ServerName ericlondon.com
ServerAlias mobile.ericlondon.com
DocumentRoot /var/www/vhosts/ericlondon.com/httpdocs
</VirtualHost>
<?php
/**
* Mobile Theme Configuration
*/
// define mobile http host
define('MOBILE_HTTP_HOST', 'mobile.ericlondon.com');
// define mobile theme
define('MOBILE_THEME','singular');
// override custom theme for mobile site
if ($_SERVER['HTTP_HOST'] == MOBILE_HTTP_HOST) {
$GLOBALS['custom_theme'] = MOBILE_THEME;
}
// check for iPhone
$is_iphone = preg_match('/iphone/i', $_SERVER['HTTP_USER_AGENT']);
// redirect to mobile theme
if ($is_iphone && $_SERVER['HTTP_HOST']!=MOBILE_HTTP_HOST) {
header('Location: http://' . MOBILE_HTTP_HOST . $_SERVER['REQUEST_URI']);
die;
}
?>
<?php
function MYMODULE_preprocess_page(&$vars) {
// only process page variables if this is the mobile address
if ($_SERVER['HTTP_HOST'] != MOBILE_HTTP_HOST) {
return;
}
// define mobile javascript
/*
NOTE: this jQuery is very specific to my theme, and is just shown as an example.
I looked into using jquery_ui's accordion library, but it would not work out of the box with the structure of my new mobile theme :(
In an ideal situation, all jQuery would be put in separate include files
*/
$js = "
// define node container
var node_container = '.front #page #content';
// define function to collapse node content
function collapse_nodes() {
$(node_container + ' .node div').hide();
}
// define function to add click event
function node_title_add_click() {
$(node_container + ' .node h2.node-title a').click(function(){
collapse_nodes();
$('div', $(this).parent().parent()).show();
return false;
});
}
$(document).ready(function(){
collapse_nodes();
node_title_add_click();
});
";
drupal_add_js($js, 'inline');
// rebuild scripts variable
$vars['scripts'] = drupal_get_js();
// determine a list of hrefs to remove from primary navigation
$href_remove = array(
'drupal',
'tagadelic/chunk/1',
'recent-posts',
'rss.xml',
'logout',
'contact',
);
// loop through primary links and remove as necessary
if (is_array($vars['primary_links'])) {
foreach ($vars['primary_links'] as $key => $value) {
if (in_array(strtolower($value['href']), $href_remove)) {
unset($vars['primary_links'][$key]);
}
}
}
}
?>
<?php
function helper_menu() {
$items = array();
$items['js-vars'] = array(
'title' => t('Javascript Variables'),
'description' => t('Javascript Variables'),
'page callback' => 'helper_page_callback_js_vars',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
return $items;
}
?><?php
function helper_page_callback_js_vars() {
// include module javascript file
drupal_add_js(drupal_get_path('module','helper') . '/js/helper.js');
// define variables you'd like to pass to the DOM
$js_vars = array(
'js_vars' => array(
'message' => t('Hello @username', array('@username' => $GLOBALS['user']->name)),
'an_array' => array(
'color' => t('red'),
'name' => t('Eric'),
),
),
);
// pass variables to javascript
drupal_add_js($js_vars, 'setting');
// generate some page output
return "TEST";
}
?>
$(document).ready(function(){
// debug variables directly in FireBug
console.debug(Drupal.settings.js_vars);
// popup mesage passed from Drupal
alert(Drupal.settings.js_vars.message);
});



regions[ad_left] = Ad Left
regions[ad_right] = Ad Right
<?php if ($ad_left): ?>
<div id='ad_left' class='google_ads'>
<?php print $ad_left; ?>
</div>
<?php endif; ?>
<?php if ($ad_right): ?>
<div id='ad_right' class='google_ads'>
<?php print $ad_right; ?>
</div>
<?php endif; ?>
.google_ads {
position: absolute;
bottom: 10px;
width: 120px;
height: 600px;
display: none;
}
.google_ads .block {
padding: 0;
margin: 0;
}
body > .google_ads {
position: fixed;
}
#ad_left {
left: 10px;
}
#ad_right {
right: 10px;
}
$(document).ready(function(){
// per IE ads
if ($.browser.msie) {
$('.google_ads').show();
}
});
cck
filefield
imageapi
imagecache
imagefield




<?php
function YOURTHEME_preprocess_node(&$variables) {
// test for carousel node type
if ($variables['type'] == 'carousel') {
// include jCarousel javascript
drupal_add_js(path_to_theme() . '/jcarousel/lib/jquery.jcarousel.js');
// add jquery in enable jQuery carousel on <ul>
$js = "
$(document).ready(function(){
$('#mycarousel').jcarousel();
});
";
drupal_add_js($js, 'inline');
// include jCarousel css
drupal_add_css(path_to_theme() . '/jcarousel/lib/jquery.jcarousel.css');
drupal_add_css(path_to_theme() . '/jcarousel/skins/tango/skin.css');
// loop through images and create an item list
$items = array();
foreach ($variables['field_images'] as $key => $value) {
$items[] = $value['view'];
}
// ensure images exist
if (count($items)) {
// add jQuery carousel html to $content variable
$variables['content'] .= theme('item_list', $items, NULL, 'ul', array('id' => 'mycarousel', 'class' => 'jcarousel-skin-tango'));
}
}
}
?>
div.field-field-images {
display: none;
}
