ethon wiliams ethon wiliams - 1 month ago 12
PHP Question

How to connect Drupal and Views to External Databases

We often get asked whether Drupal can show information from other websites.

In particular, people want to pull information and display it through Views so i want to know that things how to connect Drupal and Views to External Databases.

anyone know about that things or is drupal support any modult for this, give me good solution for this.

Answer

The Views Database Connector module makes this relatively easy. Let’s show you how it’s done.

First, install Views Database Connector from Drupal.org

Second, go to your sites/default/settings.php file. You will need to edit this file to include the connection information for the new database. The settings.php file already contains information for your current Drupal site. You need to add a second array to include the new database login details. Here’s how the code will

enter image description here

then after

  • Clear the cache on your site to make sure the new settings.php file is being used.
  • Go to Structure > Views > Add new view.
  • Under the “Show” dropdown, you’ll now see all the available tables from your other database:

enter image description here

From this point on, you can use Views to show external data, in exactly the same way as you show Drupal data.