Skip to content

Instantly share code, notes, and snippets.

View knibals's full-sized avatar

Oumar Fall knibals

View GitHub Profile
@knibals
knibals / Select theme by IP address
Created April 25, 2013 10:01
Select a specific theme by IP address (may be useful when THEMERS work collaboratively with DEV people)
<?php
/**
* @file helpers.module
*/
/**
* Implements hook_custom_theme().
* Activer le theme uniquement pour le themer (par adresse IP)
*/
@knibals
knibals / drupal_jquery_from_cdn.php
Created October 23, 2012 13:00
Retrieve jQuery from CDN (hook_js_alter)
/**
* Implements hook_js_alter().
*/
function YOUR_THEME_js_alter(&$js) {
if (isset($js['misc/jquery.js'])) {
$jquery_path = 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js';
$js['misc/jquery.js']['data'] = $jquery_path;
$js['misc/jquery.js']['version'] = '1.8.0';
$js['misc/jquery.js']['type'] = 'external';
}
@knibals
knibals / gist:2491501
Created April 25, 2012 17:31 — forked from mrconnerton/gist:1979037
node form in ctools modal drupal 7
<?php
/**
* Implements hook_menu().
*/
function mymodule_menu() {
$items['mymodule/%ctools_js/add'] = array(
'page callback' => 'mymodule_node_add_modal_callback',
'page arguments' => array(1),
'access arguments' => array('access content'),
<?php
/**
* Implements hook_form_alter().
*
* Redirects user logins to the front page.
*/
function HOOK_form_user_login_alter(&$form, &$form_state) {
$form['#action'] = url('user', array('query' => array('destination' => '<front>')));
}