Drupal Interview Questions and Answers :
1. How does caching work in Drupal?
One of the common (mostly unfounded) complaints about Drupal has been, "Drupal is slow." You want to hire a developer who understands Drupal's built in caching system, and what its limitations are. For example, Drupal 6's block cache will not appreciably speed up the page if the user is logged in.
Ask your candidate to recommend some additional solutions to speed up Drupal's caching. These could include the Boost module, Varnish, Squid, Memcache or Pressflow. Ask if they've ever run into issues with Drupal's cache.
2. How to make my Drupal site offline to public, while it is under construction?
You can set your Drupal site in off-line mode, while it is being developed. Just click Administer » Site maintenance. There you can set the status to off-line. If you wants, you can also set your own custom off-line message. When set to Off-line, only users with the administer site configuration permission will be able to access your site to perform maintenance; all other visitors will see the site off-line message configured there. Authorized users can log in during Off-line mode directly via the user login page.
3. How can I install a new theme in Drupal?
This is another common question among Drupal newbies all time. After trying out all available themes under Drupals theme directory, we may naturally want to try new themes. Installing a new theme is very simple and straightforward. Follow the steps below.
Download a new theme package. Note that themes for different Drupal versions are not compatible, version 5.x themes do not work with Drupal 6.x and reverse.
Read any README or INSTALL files in the package to find out if there are any special steps needed for this theme.
Upload the contents of the theme package to a new directory in the themes directory in your Drupal site. In Drupal 5.x & 6.x, you place your themes in /sites/all/themes/yourThemeName
Click administer » themes and enable the new theme (Drupal will auto-detect its presence).
Edit your user preferences and select the new theme. If you want it to be the default theme for all users, check the default box in the themes administration page.
4. What is a Module in drupal ?
A module is software (code) that extends Drupal features and/or functionality. Drupal Supports – Core modules – included with the main download of Drupal, and you can turn on their functionality without installing additional software. Contributed modules are downloaded from the Modules download section of drupal.org, and installed within your Drupal installation. You can also create your own module – CustomModules” using PHP programming, and Drupal’s module API.
5. What modules do you always recommend and why?
6. What is hooks?
Ans:Allow modules to interact with the Drupal core.
Drupal’s module system is based on the concept of “hooks”. A hook is a PHP function that is named foo_bar(), where “foo” is the name of the module (whose filename is thus foo.module) and “bar” is the name of the hook. Each hook has a defined set of parameters and a specified result type.
8. Which files are required for theme?
Ans: style.css, page.tpl.php, info file, template.php, node.tpl.php, block.tpl.php
9. What makes “Search” in drupal as an excellent feature than Other CMS?
Drupal uses search indexing using content type, classification information from taxonomy system and the content meta data.
Drupal treats its content as fine-grained semantic information that Drupal knows about can be used to fine-tune search results.
Also, you can tweak and override the search system to adjust the user interface, the way content is ranked, and the way results are displayed. That said, Drupal integrates well with external search engines such as Apache Solr, Xapian, and Sphinx if the built-in search does not meet your needs very easily.
10. what is PDO?
Ans: PDO is an acronym for PHP Data Objects. PDO is a lean, consistent way to access databases. This means developers can write portable code much easier. PDO is not an abstraction layer like PearDB. PDO is a more like a data access layer which uses a unified API (Application Programming Interface).
11. How PDO used in drupal?
Ans: Drupal provides a database abstraction layer to provide developers with the ability to support multiple database servers easily. The intent of this layer is to preserve the syntax and power of SQL as much as possible, but also allow developers a way to leverage more complex functionality in a unified way. It also provides a structured interface for dynamically constructing queries when appropriate, and enforcing security checks and similar good practices.
12. How to install a new module in Drupal?
After finding and downloading a module, the next step would be to copy it the modules folder. Most people copy the file to the default modules folder here http://sitename.com/drupal/modules this is where all the modules that ship with Drupal are stored so it seems somewhat logical to do this. But this folder is actually meant to store only Drupal’s default modules. Instead you should go to http://sitename.com/drupal/sites/all folder, there you will see a readme.txt file. This file will clearly tell you the trick. You just need to create a new folder named modules here. Now copy the modules folder here. That’s all, you have successfully installed the module.
Next step would be to enable the module through the Admin interface. To do this navigate to Administer » Site Building » Modules. Here you will see a list off all installed modules, and our newly installed module will also be listed here. You just have to check the enable check box against the new module and then click the Save Configuration button. That’s all.
13. How can I reset my Drupal admin password?
In such a worst scenario, drupal admin password can easily be reset from the Drupal database. The Drupal database can be accessed through phpMyAdmin tool available with your web hosting account. Follow the below steps to get your drupal admin password reset quickly:
· Login to cPanel -> Databases box -> phpMyAdmin;
· Select the Druapl database folder from the left navigation bar. The page will refresh and and the Drupal database’s tables will be displayed on it.
· Click on the SQL tab.
· In the text field write the following SQL query:
update users set pass=md5(’NEWPASS’) where uid = 1; where “NEWPASS” is your new Drupal administrative password.
Click the GO button to submit the query. If the query is executed correctly and no errors are displayed then you should be able to login with the new password.
14. How can I change the favicon in my Drupal Site?
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. If you want to make your site unique by all means, you can easily change the favicon to your customized icon by following the steps below.
· 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.
15. How can we set the region in drupal theme?
You can set the regions in themename.info file. Following is the example: regions[header] = Header regions[content_header] = Content Header regions[content] = Content regions[sidebar_second] = Right sidebar
16. What is left join and right joins?
For the sake of this example, lets say you have 100 students, 70 of which have lockers. You have a total of 50 lockers, 40 of which have at least 1 student.
INNER JOIN is equivalent to “show me all students with lockers”.
Any students without lockers, or any lockers without students are missing. Returns 70 rows
LEFT OUTER JOIN would be “show me all students, with their corresponding locker if they have one”.
This might be a general student list, or could be used to identify students with no locker. Returns 100 rows
RIGHT OUTER JOIN would be “show me all lockers, and the students assigned to them if there are any”.
This could be used to identify lockers that have no students assigned, or lockers that have too many students. Returns 80 rows (list of 70 students in the 40 lockers, plus the 10 lockers with no student)
FULL OUTER JOIN would be silly and probably not much use.
Something like “show me all students and all lockers, and match them up where you can” Returns 110 rows (all 100 students, including those without lockers. Plus the 10 lockers with no student)
CROSS JOIN is also fairly silly in this scenario.
It doesn’t use the linked “lockernumber” field in the students table, so you basically end up with a big giant list of every possible student-to-locker pairing, whether or not it actually exists. Returns 5000 rows (100 students x 50 lockers). Could be useful (with filtering) as a starting point to match up the new students with the empty lockers.
17. How to create the table using module?
Use following code: /** * Implements hook_schema(). */ function module_name_schema() { $schema[‘module_name’] = array( ‘fields’ => array( ‘type’ => array(‘type’ => ‘varchar’, ‘length’ => 15, ‘not null’ => TRUE, ‘default’ => ‘node’), ‘id’ => array(‘type’ => ‘int’, ‘unsigned’ => TRUE, ‘not null’ => TRUE, ‘default’ => 0), ‘module_name’ => array(‘type’ => ‘varchar’, ‘length’ => 255, ‘not null’ => TRUE, ‘default’ => ”) ), ‘primary key’ => array(‘type’, ‘id’), );
return $schema;
}
/**
* Implements hook_uninstall(). */ function module_name_uninstall() { // Clear variables variable_del(‘module_name_default’);
}
How to update table using module?
Ans: You can check the following code: /** * Implements hook_update_n(). */ function module_name_update_6200() { $ret = array();
if (db_column_exists(‘module_name’, ‘id’)) {
return $ret; }
db_create_table($ret, ‘module_name_temp’, array(
‘fields’ => array( ‘type’ => array(‘type’ => ‘varchar’, ‘length’ => 15, ‘not null’ => TRUE, ‘default’ => ‘node’), ‘id’ => array(‘type’ => ‘int’, ‘unsigned’ => TRUE, ‘not null’ => TRUE, ‘default’ => 0), ‘module_name’ => array(‘type’ => ‘varchar’, ‘length’ => 255, ‘not null’ => TRUE, ‘default’ => ”) ), ‘primary key’ => array(‘type’, ‘id’), ));
$ret[] = update_sql(‘INSERT INTO {module_name_temp} (id, module_name) SELECT nid, module_name FROM {module_name}’);
db_rename_table($ret, ‘module_name’, ‘module_name_old’);
db_rename_table($ret, ‘module_name_temp’, ‘module_name’);
$display_settings = variable_get(‘module_name_display’, array());
foreach ($display_settings as $type) { if ($type) { variable_set(‘module_name_type_’ . $type . ‘_showfield’, 1); } } variable_del(‘module_name_display’);
return $ret;
}
17. How to drop the table using module?
Use db_drop_table method in install file
18. What is responsive theme?
A responsive theme (as the one used for this website), is an approach to web development that allows a website to break itself down smoothly across multiple monitor sizes, screen resolutions, and platforms, be it a computer, tablet or mobile device. It allows the developer to create a site that is optimized for each platform, both in navigation, readability and load time.
As you can see when resizing the window (if you are viewing this site on a computer), the layout of the page shifts depending on the size of the screen; with different layouts for content depending on viewing area. Themes (or layouts) such as this, allow for a single site and single look to the site, to be viewed on various devices without the need for additional themes or resizing by the user.
19. What is difference between innodb and myIsam?
First major difference I see is that InnoDB implements row-level lock while MyISAM can do only a table-level lock. You will find better crash recovery in InnoDB. However, it doesn’t have FULLTEXT search indexes, as does MyISAM. InnoDB also implements transactions, foreign keys and relationship constraints while MyISAM does not.
20. What is difference between update and alter query?
ALTER is a DDL (Data Definition Language) statement. Whereas UPDATE is a DML (Data Manipulation Language) statement. One is used to update the structure of the table (add/remove field/index etc). Whereas UPDATE is used to update data.
21. What is purpose or use of .htaccess file?
File_HtAccess provides common methods to create and manipulate Apache / NCSA style .htaccess files. These files together with accompanying password files are used to protect webserver directories. Since File_HtAccess does not provide any means to manipulate or create password files you should use it together with File_Passwd.
22. What is use of substr and strstr function?
strstr — Find the first occurrence of a string. substr — Return part of a string.
23. Can we include one php file multiple times?
Ans: Yes.
24. What is contextual filter?
contextual filters were called arguments in Views and a lot of documentation, tutorials and Views-compatible modules still use that term. If you see the term argument, it should be interpreted either as a contextual filter, or the value provided to a contextual filter.
25. How to use the contextual filter?
Ans: The classic example of how contextual filter values are provided to views is by the view path. If a view has the path example.com/my-view, the URL example.com/my-view/story/22 will call the view along with two values for contextual filters (in this case story and 22). But there are more ways of providing contextual filter values. These are discussed in Chapter about Page manager and Panels.
26. What is taxonomy?
Taxonomy, a powerful core module, gives your sites use of the organizational keywords known in other systems as categories, tags, or metadata. It allows you to connect, relate and classify your website’s content. In Drupal, these terms are gathered within “vocabularies.” The Taxonomy module allows you to create, manage and apply those vocabularies.
New under Drupal 7 is the ability to add taxonomy fields to vocabularies and terms.
27. How to update the drupal?
Easiest way is use update.php file. If you installed the drush then you can use the following command “drush pm-update”. Do not forget to take file and mysql backup before update.
28. 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.
29. 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
30. 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.
31. 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.
32. 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.
33. Which Design Pattern used in Drupal?
Singleton Design pattern is used in Drupal.
34. What is the use of features module?
The features module enables the capture and management of features in Drupal. A feature is a collection of Drupal entities which taken together satisfy a certain use-case.
Features provides a UI and API for taking different site building components from modules with exportables and bundling them together in a single feature module. A feature module is like any other Drupal module except that it declares its components (e.g. views, contexts, CCK fields, etc.) in its .info file so that it can be checked, updated, or reverted programmatically.
35. Did you used the Panel module? If yes then what is the use of that?
The Panels module allows a site administrator to create customized layouts for multiple uses. At its core it is a drag and drop content manager that lets you visually design a layout and place content within that layout. Integration with other systems allows you to create nodes that use this, landing pages that use this, and even override system pages such as taxonomy and the node page so that you can customize the layout of your site with very fine grained permissions.
36. What is the use of Ctools module?
This suite is primarily a set of APIs and tools to improve the developer experience. It also contains a module called the Page Manager whose job is to manage pages. In particular it manages panel pages, but as it grows it will be able to manage far more than just Panels.
37. 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.
38. 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.
39 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
40. How can I 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.
41. How do I 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; ?>
42. How can I 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.
43. How do I move a Drupal Site from One host/server to another?
Answer:- Migrating Drupal On your OLD host:
1) 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.
2) 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
On your NEW host:
1) Upload your folder with the complete drupal installation to your home-directory.
2) 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.
3) Import (upload) the database (which you exported from the old host earlier) with phpadmin to the new database. This might take a minute.
4) 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.
5) Chmod your "files" folder so it is writeable using your ftp client (filezilla), chmod to 777
6) 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.
44. How to backup my Drupal site?
Answer:- 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.
45. How to Customize my 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.
46. 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.
|
Thanks for sharing! Right interview questions are important to choose your candidate correctly, but not the most important thing, check how and where to hire Drupal developers and what should you watch out for when hiring Drupal developers - https://anyforsoft.com/blog/how-hire-and-interview-drupal-developers
ReplyDelete