Drupal Camp Mumbai 2011 – Day 1

Filed in Open Source | Technology Leave a comment

I had an excellent time with fellow drupalars at Drupal Camp Mumbai held at IIT, Powai. It feels great to put faces to irc nicknames and meet the people for real. This always amazes me :) .

I was bit late hence missed drupal song ( which I heard was fun ) but reached in time for keynote by Dries Buytaert, original creator and project lead for the Drupal. Dries spoke about early days of drupal and how it has evolved into one of the successful open source project. He also emphasized on having a strong community and then shared his thoughts on drupal’s future.

Jacob Singh’s “How to have an open relationship with software (and still get paid) – Free software in material world“, mainly focussed on how each one of us can benefit by being part of drupal community and  in the process grow as a individual/company within drupal community. I really liked his presentation, especially self portraits :)

Drupal Entities Unleashed – Create your own information architecture with Drupal” by Mukesh Agarwal was a good introduction to entities in drupal. He started with basic concepts and then went on to code level details.

Drupal, Migrating to Drupal was never so easy“ by Piyuesh Kumar & Dipen Chaudhary demonstrated migration of ROR website into drupal using migrate module. They covered various features of migrate module and it’s integration with drush. It was a great mix of  code and actual migration process. This was followed by a good Q& A session.

This kind of summarizes my day at DCM and looking forward for tomorrow’s code sprint. If you guys missed today, don’t miss tomorrow, there are some kool sessions scheduled along with code sprint.

c ya tomorrow :)

 

, ,

Integrating IMCE Drupal module with CiviCRM CKEditor

Filed in Open Source | Technology 5 Comments

CiviCRM comes with CKEditor as a default wysiwyg editor. One of the missing feature has been ability to upload /browse existing files on the server using CKEditor. So after some investigation I figured out you can easily integrate IMCE drupal module for this purpose.

Here are the steps:
1. Install IMCE module: http://drupal.org/project/imce
2. Modify packages/ckeditor/config.js

Index: config.js
===================================================================
— config.js (revision 31357)
+++ config.js (working copy)
@@ -9,6 +9,10 @@
// config.language = ‘fr’;
//config.uiColor = ‘#AADC6E’;

+ config.filebrowserBrowseUrl = ‘/index.php?q=imce&app=ckeditor|url@txtUrl|width@txtWidth|height@txtHeight’;
+ config.filebrowserImageBrowseUrl = ‘/index.php?q=imce&app=ckeditor|url@txtUrl|width@txtWidth|height@txtHeight’;
+ config.filebrowserFlashBrowseUrl = ‘/index.php?q=imce&app=ckeditor|url@txtUrl|width@txtWidth|height@txtHeight’;
+
// disable auto spell check
config.scayt_autoStartup = false;

3. Clear you browser cache
4. That’t it, now when you click on image icon you will get option to “Browse Server”, using which you can browse existing file or upload new files on the server.

By default you can browse / upload files only to files directory.

Sorry joomla people.. this will work only for drupal.

, , ,

How to remove default title set by drupal

Filed in Open Source | Technology Leave a comment

You can implement a module and call below function

function modulename_preprocess_page(&$variables) {
unset($variables['title']);
}

This will unset default title, but there are 2 problems:
1. This hook is not called by all the themes. So you cannot entirely rely on this.
2. Some themes check if ‘title’ exits before showing breadcrumb. So if you unset title then your breadcrumb will also disappear.

So finally I came up with this hack.

drupal_set_title( ‘ ‘ );

Note that there is space  between single quotes. This removes default title

,

My notes: Upgrading CiviCRM v2.1 to CiviCRM v3.1 ( Drupal / Joomla )

Filed in Open Source | Technology Leave a comment

Recently we successfully upgraded one of our client CiviCRM install from v2.1 to v3.1.2. Over all I was pretty happy with the CiviCRM upgrade process considering client’s db was in bad shape. This client is one of the early adopters of CiviCRM, ( since v1.8 ) that made things bit worse.

Few things you should remember before starting upgrade:

1. Backup your working CiviCRM database

If you have demo / test server try to upgrade it first rather than live. Always keep backup of your current working CiviCRM database so that you can revert back if needed.

2. Ensure Database Integrity

Never assume client’s database structure is correct, it might be upgraded and hence might be missing foreign key constraints etc, especially if it is been upgraded from CiviCRM v1.x. This might lead to more errors and will take more time to fix / result in more issues during upgrade process.

3. Understand upgrade errors

Try to figure out why you get errors during upgrade process rather than commenting sql or php code in CiviCRM.

4. Fix current database issues

If you get any sql errors during upgrade try to fix your current database. Most of the time database might have stale data.

So based on above, we followed these steps:

1. Backup CiviCRM database. I usually do it via command prompt.( you can also use phpmyadmin or any other database qui’s )

mysqldump -u DBUSER -p PASSWD DBNAME > civicrm_backup.mysql

2. We followed these steps to ensure database integrity before upgrade:

- Export only data from current CiviCRM database. Before exporting I would suggest you should empty cache tables in CiviCRM.

civicrm_cache, civicrm_group_contact_cache, civicrm_acl_cache, civicrm_acl_contact_cache

Then take database backup:

mysqldump5 -c -e -t -n -u DBUSER -p PASSWDS DBNAME > civicrm_only_data.mysql

- Drop current database

mysqladmin -f -u DBUSER -p $PASSWD drop DBNAME

- Create new database and import structure from sql/civicrm.mysql ( from your current install, so in this case creating structure for CiviCRM v2.1 )

mysqladmin -f -u DBUSER -p $PASSWD create DBNAME

mysql -u DBUSER -p PASSWD DBNAME < civicrm.mysql

- Now import data which you exported

mysql -u DBUSER -p PASSWD DBNAME < civicrm_only_data.mysql

After these steps make sure your CiviCRM is working without any errors.

Now you are ready for actual upgrade process :)

1. Upgrade CiviCRM v2.1 to latest 2.2.x release using following instructions:

2. Make sure everything is working fine. If yes than take database backup using instructions mentioned above. ( so that you have db to revert if next upgrade fails )

3. Upgrade CiviCRM v2.2.x to CiviCRM v3.1.x using these instructions:

During this upgrade we got few sql errors:
- We got foreign key contraint failure error when following SQL was fired by CiviCRM

ALTER TABLE `civicrm_activity`

ADD CONSTRAINT `FK_civicrm_activity_source_contact_id` FOREIGN KEY (`source_contact_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE SET NULL;

We got this error because civicrm_activity table in client’s db had wrong values. For few records “source_contact_id” value didn’t exist in civicrm_contact table. So we did source_contact_id = NULL for those activity records.

- Error

DB Error: constraint violation Database Error Code: Cannot add or update a child row: a foreign key constraint fails (`database_civicrm/civicrm_group_contact_cache`, CONSTRAINT `FK_civicrm_group_contact_cache_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE), 1452

This was because civicrm_group_contact table had entries for contacts that didn’t exits in civicrm_contact table. So we deleted those entries from civicrm_group_contact table.

Note that after each failed step you should rollback to previous working copy / fixed copy.

I agree this process looks bit complicated :) but trust me it might help you to save lot of time in debugging upgrade errors and ensure smooth future upgrade. It took me around 3-4 hours for upgrading this install from CiviCRM v2.1 to CiviCRM v3.1

I hope this helps someone :)

, , ,

Configuring multiple CiviCRM on single Drupal

Filed in Open Source | Technology 3 Comments

This instructions were originally written for Ubuntu, but can be used for other operating systems.

We will setup http://civicrm , which will be on CiviCRM trunk and http://civicrm21, which will be on CiviCRM v2.1 branch.

1. Download Drupal from drupal.org. Untar and copy it to /var/www/drupal-6.6.
2. We need multi-site Drupal setup. So create “civicrm” folder in sites/ .
3. Now we need to define Virtualhost in apache. You can read instructions from: http://httpd.apache.org/docs/2.2/vhosts/name-based.html
OR you can follow my instructions:

i) In your /etc/apache2/site-available. Create new file civicrm and copy below code
<VirtualHost *:80>
ServerName civicrm

DocumentRoot /var/www/drupal-6.6
<Directory /var/www/drupal-6.6/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

ErrorLog /var/log/apache2/civicrm_error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/civicrm_access.log combined

</VirtualHost>

ii) sudo a2ensite civicrm
iii) sudo /etc/init.d/apache2 restart

This will create apache virtual host.

Then modify your /etc/hosts and to add new site “civicrm”

127.0.1.1    civicrm

Restart your network: sudo /etc/init.d/networking restart

4. Now you new site is ready and you can install drupal using http://civicrm

While installing you might get errors like;

“Copy the ./sites/civicrm/default.settings.php file to ./sites/civicrm/settings.php”

So copy sites/defaults/default.setting.php to sites/civicrm/settings.php

If you want clean url’s edit your .htaccess accordingly.

Important Note:

For your second site ie. http://civicrm21 you need to follow few more steps:
- take a drupal database table “system” dump (structure and data)
- create another new table for 21_system with above above dump
- add db prefix in your settings.php
$db_prefix = array( ‘system’ => ’21_’);
- specify $cookie_domain in your settings.php ( for eg civicrm21 )

5. After that install CiviCRM, you can get it from http://civicrm.org

Untar and copy civicrm folder in “sites/civicrm/modules/”.

Just in case you are running civicrm from svn. Then your settings_location.php should be like:

define( ‘CIVICRM_CONFDIR’, ‘/var/www/drupal-6.6/sites/civicrm’ );

For installing another instance of civicrm you need to create another site in drupal. So sites/civicrm21. Then repeat above steps.

So http://civicrm (CiviCRM trunk) and http://civicrm21 (CiviCRM v2.1)

Enjoy CiviCRM and Drupal :)

, ,

TOP