Recent articles

Create list view in custom module (part 2)

In previous article we have seen how to declare the data accessible in a custom view in MyModule.

Now that the data from our tables mymodule_tb (and mymodule_tb_2) are available, let's create the list view.

First navigate to "/admin/structure/views/add" and create the view by entering basic information as per the example below.

 

New view basic info

 

After "save" you are redirected to "Edit" form where further settings will be set.

1) Add fields from you source table

Add fields

 

 

From this form, select the fields to display. We will select 2 here "name" and "type" (refer to the table structure declared in MyModule_views_data())

Create list view in custom module (part 3)

In previous articles (here and here), we have seen a method to add custom views and data in MyModule.

With Drupal 8 there is a very easy and practical way to add this custom view as a configuration that will be installed with the module.

1) extract the configuration data

Navigate to "/admin/config/development/configuration/single/export".

On this page, select configuration type 'view' and configuration name 'My module list' that was created earlier.

 

Single export

 

2) create configuration install file

You will obtain from the above export a list of configuration data that you can copy and paste into a file called for instance "views.view.mymodule-list.yml";

Simply place this file into the install folder :

Configuring Drupal with remote database

Configuring Drupal with a remote database is possible and in some cases recommended.

Our Drupal 8 EK management tools application is a particularly good case where this setup is very helpful. EK manages Drupal system configuration database and content database separately. In other words, the installed database from Drupal 8 and the database where all EK custom modules save their data are different.

This configuration brings few benefits:

Articles

<p>The objective of those articles is to share some experience on how we do things ans sometime struggle at getting things done properly both from technical and organisational point of view.</p>

<p>We do not provide definitive knowledge but rather would like to initiate discussion on how to do and how to do better.</p>

<p>Thank you reading; we hope our topics will be of interest.</p>

<p>&nbsp;</p>