Drupal Interview Questions & Answers
Download PDF

Drupal Interview Questions and Answers will guide us now that Drupal is a free and open source Content Management System (CMS) written in PHP and distributed under the GNU General Public License. It is used as a back-end system for many different types of websites, ranging from small personal blogs to Enterprise 2.0 collaboration. Learn Drupal Programming by this Drupal Interview Questions and Answers guide

40 Drupal Questions and Answers:

Drupal Interview Questions Table of Contents:

Drupal Job Interview Questions and Answers
Drupal Job Interview Questions and Answers

1 :: Explain coding standards in Drupal?

As per the Coding standards, omit the closing ?> tag. Including the closing tag may cause strange runtime issues on certain server setups. (Note that the examples in the handbook will show the closing tag for formatting reasons only and you should not include it in your real code.)
All functions in your module that will be used by Drupal are named {modulename}_{hook}, where "hook" is a pre-defined function name suffix. Drupal will call these functions to get specific data, so having these well-defined names means Drupal knows where to look. We will come to hooks in a while.

2 :: How to create a folder and a module file in Drupal?

Given that our choice of short name is "onthisdate", start the module by creating a folder in your Drupal installation at the path: sites/all/modules/onthisdate. You may need to create the sites/all/modules directory first. Create a PHP file and save it as onthisdate.module in the directory sites/all/modules/onthisdate. As of Drupal 6.x, sites/all/modules is the preferred place for non-core modules (and sites/all/themes for non-core themes), since this places all site-specific files in the sites directory. This allows you to more easily update the core files and modules without erasing your customizations. Alternatively, if you have a multi-site Drupal installation and this module is for only one specific site, you can put it in sites/your-site-folder/modules.
The module is not operational yet: it hasn't been activated. We'll activate the module later in the tutorial.

3 :: How to name your module?

The first step in creating a module is to choose a "short name" for it. This short name will be used in all file and function names in your module, so it must start with a letter and by Drupal convention it must contain only lower-case letters and underscores. For this example, we'll choose "onthisdate" as the short name. Important note: It is not just a convention that the short name is used for both the module's file name and as a function prefix. When you implement Drupal "hooks" (see later portions of tutorial), Drupal will only recognize your hook implementation functions if they have the same function name prefix as the name of the module file.
It's also important to make sure your module does not have the same short name as any theme you will be using on the site.

4 :: Explain the menu system in Drupal?

Define the navigation menus, and route page requests to code based on URLs.
The Drupal menu system drives both the navigation system from a user perspective and the callback system that Drupal uses to respond to URLs passed from the browser. For this reason, a good understanding of the menu system is fundamental to the creation of complex modules. Drupal's menu system follows a simple hierarchy defined by paths. Implementations of hook_menu () define menu items and assign them to paths (which should be unique). The menu system aggregates these items and determines the menu hierarchy from the paths. For example, if the paths defined were a, a/b, e, a/b/c/d, f/g, and a/b/h, the menu system would form the structure:
a
a/b
a/b/c/d
a/b/h
e
f/g

5 :: How to interact with Drupal search system?

There are three ways to interact with the search system:
Specifically for searching nodes, you can implement nodeapi ('update index') and nodeapi ('search result'). However, note that the search system already indexes all visible output of a node, i.e. everything displayed normally by hook_view () and hook_nodeapi ('view'). This is usually sufficient. You should only use this mechanism if you want additional, non-visible data to be indexed.
Implement hook_search (). This will create a search tab for your module on the /search page with a simple keyword search form. You may optionally implement hook_search_item () to customize the display of your results.
Implement hook_update_index (). This allows your module to use Drupal's HTML indexing mechanism for searching full text efficiently.
If your module needs to provide a more complicated search form, then you need to implement it yourself without hook_search (). In that case, you should define it as a local task (tab) under the /search page (e.g. /search/mymodule) so that users can easily find it.

6 :: How to Customize a Drupal Syndicate Feed Icon?

For a recent project I needed to customize the feed icon in the Drupal theme I was creating. This wasn't as straight forward as I thought it would be. Being the drupal newbie that I am I went looking for it in the core templates and suggestions page only to come empty handed.
Previously I found the solution to theming a search form by using the search-block-form.tpl.php template file and thought there would be one for the feed icon too. I found the solution to this in the function reference in the form of a theme hook.
theme_feed_icon($url, $title)
This function is internally called by drupal to generate the feed icon in the Syndicate block. Our Job is to override this function.

7 :: How to backup a Drupal site?

Backing up your Drupal site is now very easy, you just need to download and install a module called Backup & Migrate. To install the module click on the Administer » Modules check the Backup and Migrate module and enable it and save the settings.
Then navigate to the Administer » Content Management » Backup and Migrate then do the following settings.
► Exclude the following tables altogether: select the table which you dont want to take backup.
► Give the backup file name.
► There are also options to compress the file before download, or add a datestamp.
► And then click Backup Database.
Alternately you can take backups using PhpMyAdmin.

8 :: How to move a Drupal Site from One host/server to another on your NEW host?

► Upload your folder with the complete drupal installation to your home-directory.
► Once done, go to phpadmin on the new host, create a new mysql database, example "name_drpl1" and create a new mysql user. Create a password for this new mysql user, click "assign all privileges" to this user and assign the user to the new database.
You now should have a new mysql database on the new host with a mysql user, eg. "name_drpl1" as database name and "name_username" as database user name.
► Import (upload) the database (which you exported from the old host earlier) with phpadmin to the new database. This might take a minute.
► If needed edit the file [drupal home]/sites/default/settings.php and edit at the section where you enter the database, location, username and password. You CAN enter the password either encrypted or not encrypted there.
► Chmod your "files" folder so it is writeable using your ftp client (filezilla), chmod to 777
► Double check your .htaccess and [drupal home] /sites/default/settings.php and make changes in case they are needed.
Change nameserves on your domain host and let them point to your new host's nameservers.
Enter the new nameservers in your control panel where your domain names are hosted, overwriting the old ones.
After some time (sometimes a day or two) your domain should point to the new host and drupal should be up and running on the new host.

9 :: How to move a Drupal Site from One host/server to another?

Migrating Drupal On your OLD host:
► Backup your whole home directory from your ftp access using an ftp client like filezilla. Make a folder on your local harddisk and download the complete directory to that local folder.
► Backup your mysql database on your old host using phpadmin, select your mysql database, usually something like "name_drpl1". Select all fields, click "export" and save the database to your local harddisk. Leave default options enabled. You will receive a file similar to "name_drpl1.sql".
This is your mysql database

10 :: How to install Drupal on a local WAMP server?

Preparing your computer with a local installation of Drupal with WampServer is comparatively a trouble-free process to follow. Since WampServer will install an Apache-server, SQL, PHP and phpMySQL on your computer, with those tools you can install and run Drupal locally even without an internet connection.

11 :: How to remove breadcrumbs from my Drupal pages?

Breadcrumbs or breadcrumb trail is a navigation aid used in drupal interfaces. Normally it appears in between the top banner area and the page title. It gives users a way to keep track of their location within programs. Breadcrumbs are really useful in a comparatively bigger website with plenty of sections and subsections. But when it comes to smaller websites, it may found useless. In those cases you may either hide it using CSS (eg. .breadcrumb {display: none;}) or in the page.tpl.php file remove the line that says <?php if ($breadcrumb) print $breadcrumb; ?>

12 :: How to add custom PHP codes in my Drupal pages or blocks?

By default, drupal will not allow inserting PHP code directly inside a post or in a block. To do this, you need to activate a drupal module called PHP filter via, Administer » Site building » Modules. Even though this module ships with drupal, it remains disabled by default.

13 :: How can I create a custom region in my Drupal template?

Adding a new region in your drupal template is not a hard thing, but its not as easy as adding a new block. It's basically a two-step process:
► define the custom region in your theme's .info file
► insert some PHP in your theme's page.tpl.php file wherever you would like the new region to appear

14 :: What does Views do and how do you use it?

Views is a practical necessity for sites built on Drupal 6, and it's imperative that your developer understands how to take advantage of it. Earl Miles has written a great summary on the Views project page.

15 :: How can I add a new Block In Drupal?

Adding a new block is a simple process in drupal 6.
► Go to Administer » Blocks and click on the Add Block link (tab).
► Fill in the form with the necessary PHP/HTML code in the block body. And click the 'Save Block' button.

16 :: How can I customize my 404 - Page not found page?

Create a new page with some extra information, so that your visitors don't ever plunge on to the default boring 404 - page not found error page.
Once this page is created:
► Remember its node ID,
► Go to Administer > Site configuration > Error reporting
► Set Default 404 (not found) page to the node ID you just created
► Save your settings
You can also use the Search 404 module as an alternative.

17 :: How to handle upgrades in Drupal?

It's a fact of life that you'll have to upgrade your Drupal installation and contributed modules fairly frequently. Your candidate should mention:
► backing up the site,
► putting it into maintenance mode
► downloading the new version of the module
► uncompressing it
► running update.php
► testing the site
► taking the site out of maintenance mode
Ideally, your candidate would also mention creating a development environment to minimize downtime. There is also a big difference between upgrading a module (process described above) and a Drupal minor version upgrade, which requires more careful patching. Drupal major version upgrades, which happen every couple years, are another can of worms entirely.

18 :: How do I show different Drupal themes on different pages?

Yeah it's possible! You can apply different themes to different pages in your drupal site simply with the help of a cool module called 'Sections'.

19 :: How do I add images to Drupal?

Image module allows users with proper permissions to upload images into Drupal. Thumbnails and additional sizes are created automatically.
Images could be posted individually to the front page, included in stories or grouped in galleries.

20 :: How can I translate Drupal to my local language?

The interface text (like the "Log in" button and the "Add new comment" text) is in English by default, but can be translated. For many languages, there are completed or partly completed translations available. (See the locale module on how to use them.)
All languages need more translation contributions. Some have only incomplete versions of the text in core, so that parts of the interface will show up in English. Others may be complete but need corrections and improvements of the language. And no language has a complete set of translations for all contributed modules.

21 :: How do I remove the title 'Navigation' from the navigation block?

To prevent the navigation block title or any other block title from appearing in the pages, just do the following.
► Navigate to Administer » Site building » Blocks and click the configure link next to the Navigation block.
► In the block configuration page, enter <none> in the Block title filed. This will override the default title for the block and remove the title.

22 :: How do I get my site to have SEO-friendly URLs?

The Pathauto module automatically generates URL/path aliases for various kinds of content (nodes, taxonomy terms, users) without requiring the user to manually specify the path alias. This allows you to have URL aliases like /category/my-node-title instead of /node/123. The aliases are based upon a "pattern" system that uses tokens which the administrator can change.

23 :: How can I enable clean URLs in Drupal?

Drupal's default URL structure is like "http://www.sitename.com/?q=node/10″ This URL format can be hard to read, and can sometimes prevent search engines from indexing all your pages properly. In this case you can eliminate this "?q=" and clean the URLs through the following steps.
Navigate to Administer » Site configuration » Clean URLs. By default, it will be disabled. Select enabled and click the save configuration button. You are done.
You can make your URLs even more cleaner with the help of path module.
Home » Administer » Site building » Modules: enable the Path Module.

24 :: How can I change the favicon in my Drupal Site?

► Create your own favicon.ico file using any graphic tools or with the help of any online favicon generator tools like dnamicdrive.
► Navigate to admin » site building » themes and click the configure link next to your current theme. This will bring up the theme configuration page.
► Here you will see a section titled Shortcut icons settings. You can either upload your favicon file or specify the path to your customized icon file.
The changes may not appear immediately in your browser, you need to clear your browser's cache and reload the page. If you have bookmarked your site, you may need to delete the bookmark and then recreate it again so that the new favicon will appear in the bookmarks menu.

25 :: Explain favicon in Drupal?

A favicon (short for favorites icon), also known as a website icon or bookmark icon is a 16×16 pixel square icon that appears near the address bar and in the bookmarks folder in a visitor's browser. By default, a drupal site shows that water drop kinda drupal logo as favicon.
Drupal Interview Questions and Answers
40 Drupal Interview Questions and Answers