Skip to content

Instantly share code, notes, and snippets.

View sadanandkenganal's full-sized avatar

Sadanand Kenganal sadanandkenganal

View GitHub Profile

One Day Workshop On Drupal

##Agenda ###Goals

  • Students attending the workshop should come away with a good understanding of what Drupal does and what types of sites it can be used for.
  • They should be exposed to the basics of building a site in Drupal.
  • They should be exposed to the modules most people use to build Drupal sites.
@sadanandkenganal
sadanandkenganal / redirect_in_drupal7.md
Last active August 29, 2015 14:01
Redirect users after login in drupal7.

How to redirect users after login in drupal?

For example, there is page called user-serach. I want to redirect to a user-search page, when the user of some ROLE 'user-search-role'.

For this, you need to implement, hook_user_login(&$edit, $account).

Complete Code

@sadanandkenganal
sadanandkenganal / update_drupal_core.md
Last active August 29, 2015 14:01
Update Drupal Core

Steps to update Drupal core with a newer version of Drupal. (Eg. Drupal 7.27 to Drupal 7.28)

1. Make a backup of your Drupal instance. (Imp. With site folder and mysql)
2. Download the latest release of Drupal version.
3. Extract the [tar ball or zip] Drupal package.
4. Set your site on maintenance mode. (Visit this admin/config/development/maintenance).
5. Delete all the files & folders inside your original Drupal instance except for /sites folder and any custom files you added elsewhere.
  1. Copy all the folders and files except /sites from inside the extracted Drupal package [tar ball or zip package] into your original Drupal instance.
@sadanandkenganal
sadanandkenganal / drupal_multisite..md
Last active August 29, 2015 14:02
Configuring a basic multisite development environment in Linux

Basic multisite environment in Linux

Step 1: Download and uncompress Drupal

You can download and uncompress Drupal by following the steps on the Download and uncompress Drupal page of the Installation guide, as this step does not differ from a normal installation.

Step 2: Set up your hosts file

Add the following lines to /etc/hosts:

@sadanandkenganal
sadanandkenganal / drupal_menu_tabs.md
Last active August 29, 2015 14:02
How to hide menu tabs, menu links and assign access permissions in Drupal 7

Hide menu tabs, menu links and assign access permissions in Drupal 7

hide "create new account" tab in "/user" page. To hide menu tabs we have to use hook_menu_alter hook. This hook changes the menu items. So here we are going to alter menu tabs that come with user module. Using this hook we can also do some other changes like title, permissions etc.

###For hiding menu tabs

Eg: Hide 'create new account' tab  and 'request password' tab.

In your Custom module
@sadanandkenganal
sadanandkenganal / drupal_add_js.md
Created June 20, 2014 06:49
Add Javascript OR CSS to Particular Content Type Page.

You should add this code in template.php file inside your custom or contributed theme.

function tb_rave_preprocess_node(&$variables) {
    if($node->type == 'contenttypename') {
      $node = $variables['node'];
      drupal_add_library('system', 'ui.tabs');
      drupal_add_css(drupal_get_path('theme', 'yourtheme') . '/example.css');
      drupal_add_css(drupal_get_path('theme', 'yourtheme') . '/example.js');
    }   
}
@sadanandkenganal
sadanandkenganal / replace_flag_links.md
Created June 24, 2014 08:32
Replace flag links by image icons in drupal 7
@sadanandkenganal
sadanandkenganal / install_ruby_on_rails.md
Last active August 29, 2015 14:19
Install Ruby on Rails (ROR) on Ubuntu 14.04

1. Install some dependencies for Ruby.

sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev

2. using rbenv(recommended : Ruby Environment). Since there are other methods also.

@sadanandkenganal
sadanandkenganal / git_push_server_port.md
Created October 6, 2015 18:06
Git push with server port

1. Git clone

git clone  ssh://user@ipaddr:port_nu/path_to_git_on_server

OR

Do it on server machine

1. login through ssh, 
 ssh user@ip -pport_nu -v
@sadanandkenganal
sadanandkenganal / terminal_appearance_mac_os_x.md
Created February 9, 2016 06:05
How to Improve the Terminal Appearance in Mac OS X

Steps to setup

  1. Open Terminal and type nano .bash_profile
  2. Paste the following :
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -GFh'