Loading…

Drupal Interview Questions and Answers

By Admin
Last update: 27 May 2020, 25 Questions
Drupal Interview Questions

Drupal is an open-source PHP content-management framework distributed under the GNU General Public License. The frame provides a back-end framework for a lot of websites worldwide. It offers a sophisticated API, and the basic installation and administration require no programming skills. It runs on any platform that supports a server capable of running PHP and a database for storing content. To get into complete the complete details about drupal interview questions, we are mentioning Questions and Answers that can be a help to you.

Advantages of Drupal
  • Quicker content authoring
  • Flexible architecture.
  • It is designed for the mobile-first environment.
  • Better language support.

The following are the Drupal Interview Questions and Answers for experienced and freshers that are most likely to be asked:

Most Frequently Asked Drupal Interview Questions

1. What is DRUSH in Drupal?

It is a very useful tool as it helps you perform various admin tasks using one or two commands in the terminal, replacing the need for many clicks and page refreshes in the UI. "DRUSH" is an awesome shell interface for managing Drupal right from our cloud server using command line.

2. How caching works in Drupal 8?

Drupal consists of multiple layers for execution. Hence, caching is a vital aspect of Drupal to measure performance accurately.

Here are the various ways of caching in Drupal:
  • DRUPAL INTERNAL CACHING
  • CUSTOM CACHE USING DRUPAL’S CACHE API
  • DRUPAL VIEWS CACHE:
  • MEMCACHE
  • OPCODE CACHE
  • REVERSE PROXY - VARNISH
  • BOOST Caching
  • Using Content Delivery Networks(CDN)
3. What is node in Drupal?

It is a piece of individual content such as a page, poll and article. Most content on a Drupal website is stored/treated as "nodes".

4. How to enable jQuery in Drupal?

To install JQuery in Drupal, follow these steps carefully:

  • Start with downloading the jquery_ui Drupal module by using the stable version available (6.x-1.5). Now, move it to your modules folder (e.g. sites/all/modules/jquery_ui)
  • Now, go to the jQuery UI and then download the "Legacy" 1.7.x version. Not the 1.8.x version or any other later branch!
  • After completing the above step, inside a temporary directory, extract the directory "development-bundle" collected from the archive and finally rename it to "jquery.ui".
  • After renaming, start copying the renamed directory, (jquery.ui) into the sites/all/libraries folder (create a separate folder like this if it should look like sites/all/libraries/jquery.ui.)
  • Finally activate the jquery_ui module in Drupal version 8.
5. How do you enable twig to debug in Drupal 8?

While there are many methods to enable Twig Debug, this is one of the easiest and simple way

  • Step 1: Navigate to the \sites\default in the Drupal 8 dashboard.
  • Step 2: Now, start the process by making a copy of the default.services.yml file and renaming it to services.yml (if services.yml does not already exist).
  • Step 3: Next, open the file and search for this phrase 'twig.config'.
  • Step 4: Once you’ve got the phrase, set the debug mode to true, auto_reload mode to true and cache to false mode.
  • Step 5: Finally, go to the bottom of the file and copy the following code block as it is:
Parameters

twig.config:
debug: true

 

6. How to create a new theme in Drupal 8?

To create a theme in Drupal 8 from scratch, use the following steps:

  • Create a theme folder inside Drupal 8 to store your theme in a .info.yml file and libraries file.
  • Create the .info.yml file
  • Create the .libraries.yml file.
  • Start creating the stylesheets
  • Now, create designs and then, you have your own theme in Drupal 8.
7. What are the new features of Drupal 8?
  • New Theme Engine : It includes a brand new theming engine called Twig. It is PHP-based, flexible, fast, and secure.
  • Drupal 8 is mobile first now
  • It has extensive multilingual features right out of the box.
  • It has configuration management built into it at the file-system level so that carrying over configuration elements in Drupal 8.
  • Easy Authoring : It bring unprecedented power into the hands of the Content Editor, with WYSIWYG editor CKEditor now bundled with the core.
  • Views Now Part of its Core :
  • Better Support for Accessibility
  • Web Services in-Built in Drupal 8
  • In Drupal 8 it has Guided Tour
  • JavaScript Automated Testing in Drupal 8
  • Loading Speed improvement in Drupal 8.
8. How can we add Regions in Drupal Theme and list some Default Regions?

Adding regions to a theme requires two things that's are given below :-

  • Adding region meta-data to your THEMENAME.info.yml file.
  • Please edit your page.html.twig file then print new regions.

Default Regions

  • page.header
  • page.primary_menu
  • page.secondary_menu
  • page.highlighted
  • page.help (It has dynamic help text for admin pages)
  • page.content (main content of current page)
  • page.sidebar_first
  • page.sidebar_second
  • page.footer
  • page.breadcrumb
9. What is taxonomy in Drupal?

It is a powerful core module, gives our sites use of the organizational keywords known in another systems as categories or tags, or metadata. Taxonomy allows you to connect, relate and classify your website's content. These terms are gathered within "vocabularies". It is the practice of classifying content.

10. Why we used template.php in Drupal?

It allows you to override a theme function. It is available in the theme directory.

12. How to add custom PHP codes in pages using Drupal?

Drupal does not allow adding PHP code directly inside a post or in a block by default.
To do this, we need to activate a drupal module called PHP filter via Administer Site building Modules.

14. How to insert form data into the database in drupal 8?

Here is a code to insert data from the form to the table in a database in Drupal 8

Example

                                                    

public function submitForm(array &$form, FormStateInterface $form_state) {
$field = $form_state->getValues();
$name = $field['name'];
$email = $field['email'];
$field_arr = [
   'name' => $name,
   'email' => $email
];
$query = \Drupal::database();
$query->insert('users')
   ->fields($field_arr)
   ->execute();
drupal_set_message("data successfully saved");
}

15. How to fetch data from the database in Drupal 8?

To retrieve data from a database and print it, use the db_query in the following way in Drupal 8

$result = db_query('SELECT emailFROM {users} WHERE id = %d', 2);
while ( $obj = db_fetch_object ($result) ) {
print $obj->email
}
>

16. How to create rest API of tab in drupal 8?
To successfully enable a REST API tab in Drupal 8, follow these steps:
  • Download and install the REST UI contributed module.
  • Now, expose the view data as rest export using Rest UI
  • Now, create a CSRF token for completing basic authentication procedures.
  • Now, submit files to the node using the REST API
17. How to create a custom profile in Drupal 7?

In Drupal 7, custom user profiles are like fieldable entities similar to nodes. To create a new custom user profile, follow these steps:

  • First, go the Administration
  • Then, go to the Configuration tab
  • Next, click on People
  • Go to Account settings and add a new field
  • Configure the corresponding display to each user page on the Account Settings (ie. /user/$uid).
18. How do you disable commenting on articles in Drupal?
To disable comments in Drupal 8, there are two parts.
Using Drupal Admin
  • First of all, login to your Drupal admin area
  • Now, go to the Administrator tab, then Content tab and finally click on the Content Types.
  • Now, click and edit the content type you prefer to disable the comments for.
  • Lastly, you must ensure the comments are on ‘OFF’ mode by default

If you’re using Drupal 7.x/8.x use the following method to disable the comments:

  • Login to your admin area
  • Go to Structure -> Content -> Types ->Comment Settings
  • Select the option 'Closed' present under 'Default comment setting'
  • Save the changes
By executing an SQL query

Deleting/disabling the comments can also be executed by the SQL query in the phpMyAdmin. Here are the steps to follow:

Execute this SQL query in your database

UPDATE system SET status = ‘0’ WHERE filename = ‘modules/comment/comment.module’;

If you would like to reverse the effect, i.e. enable comments at a later stage, simply change the SET status = ‘1’

19. List the system requirements for Drupal installation?

Detailed system requirements for a Drupal 8 installation.

  • Websites built in Drupal 8 core are compatible with, and fully functional in, all latest browsers support CSS and JavaScript.
  • Database server to run Drupal 8
  • Drupal 8 works on web servers with PHP 5.5.9 or greater.
  • Detailed information regarding the PHP requirements for Drupal 8.
  • 32-bit PHP can only support a limited range of dates.

For more detail you can visit its official website : Click here

20. Is Drupal is a CMS? Explain

It is a Content Management Framework, from which we can build a CMS tailored specifically for our needs.

21. What do you mean by PDO in Drupal and how to enable PDO?

It is an acronym for PHP Data Objects. It is a lean, consistent way to access databases. PDO is just like a data access layer which uses a unified API.

To enable PDO, configure --enable-pdo and --with-pdo-sqlite --with-pdo-mysql or whatever database needs supporting by PDO

For windows users : For Apache, you will need to make sure php_pdo.dll and php_pdo_mysql.dll exist in the php/ext directory, un-comment or add the appropriate lines in php.ini, after that you have to restart the web server. In windows it may no longer be required to enable PDO when using newer versions of PHP, PHP version 5.3 and later. It refers to php_pdo.dll. However, you still need to activate php_pdo_mysql.dll for MySQL or for whichever database you are using.

22. What is module and List out some of the modules used in Drupal?

A Module is a collection of files which containing some functionality and is written in PHP because the module code executes within the context of the site.

In Drupal some of the modules recommended here :-

  • Views
  • Token
  • Ctools
  • Quicktabs
  • Pathauto
  • Webform
  • Google Analytics etc
23. Explain the SEO modules available in Drupal?

Some of the SEO modules available in Drupal that's are given below:-

  • Pathauto
  • Meta tags/ Node words
  • Service Links
  • Google Analytics
  • Related Links
  • Search 404
  • Site map
  • Url list
24. What are the Databases Drupal supports?

Drupal supports MySQL, MariaDB, PostgreSQL and SQLite.

25. What is the use of CTools in Drupal?

CTools or Chaos Tool Suite in Drupal is a project-oriented towards better coding for developers. It is basically a set of tutorial classes that have been simplified to explain certain workflows meanwhile also defining some custom functionalities.

Development History

Drupal was written as a message board by Dries Buytaert. In the year 2001, it became an open-source.

Latest Version: The latest version is Drupal 9.0.x released on 2nd December 2019 but might be this is not stable. The current stable version is 8.7.10 which released in 13th November 2019. This question was frequently asked in drupal 8 interview questions.