Articles

5 Excellent Tips for Drupal Development

by Deepa Ranganathan Content Writer

It's normal to have a love-hate relationship with the different development platforms. Drupal is no different, and having a deep relationship with this platform only helps you in creating good designs with excellent backend. When you begin using this platform, you are just starting out. It is your "getting to know" phase where the platform tells you all that you need to know. Once, this phase is over, you move on to having a proper relationship with the platform.

When you are moving between these two phases, it is essential to know the different tricks that might save your day. Here are five such tips that might help you with developing a website using Drupal.

Undefined Index
Most times when you go ahead with installing a distribution and follow it up with a Drupal update, you get an error that reads unidentified index:distribution_name. You can get rid of this error from your Drupal based website in two ways, both of which are given below

Add the below code to includes.inc or install.inc

if ( ! array_key_exists('distribution_name', $info)) {
$info['distribution_name'] = 'Drupal';
}

The other way to solve the issue, without disturbing the core, is to tackle the database. Once you avhe solved the issue within the database, you can clear the cache and move on. To make changes in the database, use the following code

UPDATE 'MYDATABASE'.'system' SET 'status' = '1','info' = '' WHERE 'system'.'filename' = 'profiles/MYPROFILE/MYPROFILE.profile';

Database Backup
There are different ways to create a backup for your website, which eventually depends on the size of your website.

In case you have a small website, you can use the backup and migrate module available with Drupal to backup your website.

In case of a large site, this module may not function in a proper manner for you. The best way to create a backup in this case would be to go back to the terminal and use this code

mysqldump -u root -p[root_password] [database_name] | gzip > dumpfilename.sql

In case you don't have the necessary database credentials available, you will need to use drush.

drush sql-dump --gzip --result-file

Drush is known to organize your system files during backup which can be called an advantage for you. You will see that code backups and other backups are organized into their specific directories.

Transferring Files
When you are moving between a server and your local system, your main concern would be broken images. How do you work with files when you need to move back and forth between the server and your local system?

As a regular practice, you upload the content and images to the production server, take a code and features backup and move the database to the local system. Along with the database, you will also need to move the files directory to the local system if you plan on avoiding the broken images. Drush definitely helps in transferring the files easily, but you will eat up a lot of storage space on your system with this method.

So, what is the other available technique to perform this task? Use the stage file proxy module and add the below code to settings.php file

$conf['stage_file_proxy_origin'] = 'http://example.com';

This module transfers the files that you truly need on your local system, thus avoiding unnecessary transfer of files. This module also serves the 301 redirect to your files present on the server. With this mode redirect, you can easily view the files on your local system without creating a local file directory.

Local Settings
The local settings.php file is of importance to those who work in a team development environment. Most files are stored centrally and pulled to local machines only when required. The only file that is not updated across the different systems and environments is the settings.php file. The settings cannot be kept in the central system as that can make the file vulnerable. Secondly, settings required by individual system would be different, and that is the reason it is localized.

To the settings.php file add the following code to create your local settings.php file

@include('local.settings.php');

Now add the local settings file to your central repository's .gitignore

Comparing Modules
When you are asked to make changes in an existing site, you first ensure that you have taken a backup of the database. Once you have done that, you can begin with the changes. There are chances that you may find something amiss when you are updating the website database. How would you know what went wrong- are you missing modules, or is there something wrong with the .gitignore? How will you know that?

First upload the original database, then use the code below and compare the original and modified database with the help of drush.

drush pm-list --status=enabled --type=module --pipe > enabled_modules_now.txt

Now use a diff checker available online to do the comparison check. Diffchecker.com is a great way to compare, and it will give you the details on the modules that were enabled earlier and which are disabled now, in the updated version.

Author Bio:
Deepa, a technical writer at SilverTouch (a drupal development company), who now devotes her time in advising its clients to hire Drupal developers. She offers information as well as tips and latest trends in this domain. Her love for reading helps her constantly provide latest information on different technical and design aspects of Drupal


Sponsor Ads


About Deepa Ranganathan Advanced   Content Writer

48 connections, 0 recommendations, 134 honor points.
Joined APSense since, March 27th, 2015, From Ahmedabad, India.

Created on Dec 31st 1969 18:00. Viewed 0 times.

Comments

No comment, be the first to comment.
Please sign in before you comment.