Skip to content

Instantly share code, notes, and snippets.

@raynimmo
raynimmo / Drupal Page Title
Created November 5, 2013 17:49
Drupal page-title hack; used from page.tpl.php *note GET-q will be discouraged in D8
<?php
if (!isset($path)) {
$nodepath = $_GET['q'];
}
if ($nodepath == 'contact') {
$title = 'Get In Touch';
}
if ($nodepath == 'blog') {
$title = 'Design &amp; Development Portfolio';
@raynimmo
raynimmo / login-redirect-drupal.php
Created October 5, 2013 18:21
redirect a user after login to a specific page
<?php
/**
* Implements hook_user_login().
*/
function mymodule_user_login(&$edit, $account) {
$current_path = drupal_get_path_alias($_GET['q']);
// If the user is logging in from the 'example' page, redirect to front.
if ($current_path == 'example') {
$_GET['destination'] = '<front>';
@raynimmo
raynimmo / drupal-role-action-opt
Created September 11, 2013 16:44
Drupal: opting out of actions based on current users role. Can be used in page.tpl.php
global $user;
if($user->roles[3] || $user->roles[4]){
//dont track admins or moderators
}
if($user->roles[0] || $user->roles[1] || $user->roles[DRUPAL_ANONYMOUS_RID] || user_is_anonymous()){
//track anonymous or regular users
} // endif
@raynimmo
raynimmo / Drupal SSH upgrade
Created August 28, 2013 13:52
SSH commands for version upgrade from Drupal.org
wget http://ftp.drupal.org/files/projects/drupal- <VERSION NUMBER> .tar.gz
tar -xzvpf drupal- <VERSION NUMBER> .tar.gz
cd drupal- <VERSION NUMBER>
mv *.* ../
cp -r includes misc modules profiles scripts themes ../
cd ..
rm -rf drupal- <VERSION NUMBER>
rm -rf drupal- <VERSION NUMBER> .tar.gz