Automatically populate content


This contribution deals with automatically generated content.

1) Default values

Take a field (eg image field to make a banner on each node, or a piece of text) en set content default.


Put this field in the form modus disabled. Done..

There is a Markup module that does the same..I don't see any difference.

2) Reference fields

A refence field can give the rendered entity in the display mode. As you know, one can create display modes in Drupal 8 yourself with the fields you want. So... you can show everething you want.


Here i choose the teaser mode.


3) Use of Tokens


Install the Token Filter module:

Go to the text format settings and enable the filter.


From now on you can use tokens in textfields.


The result. I added three fields together in one field..Hide the other fields..


Where can you find the tokens. Go to Help = > Token. Yes... the Help tab is usefull..


Even with reference fields one can reference to fields from another content type.

I have a content type 'paintings' with  reference field 'painters'. This content type has a name and an image field of the painter.

So i can show the image field of the painter in the node of the painting.

Look for the token in the Help tab.


The result.

You can also switch to the source code and add some CSS classes.


4) Automatic Entity label

The title field can be automatically generated with this module.


Go to the settings.


When the title is not filled in, the module does the job.


We try..


And when i fill in the title...

5) Computed fields

We are going to discuss this module with some examples..

a) Calculate a total price with a maximum of 40 €.  10 €/adults, 5€/children


The result..

Above the 40 €. (used to be 45€)


b) Generate images depending on field values.

I have a field with 2 kinds of reduction. 10 and  20


In stead of showing the numer i prefer to display an image.


The 10 % choise..


The computed field does the job. You need to give the images a specific name of course. 10.png and 20.png and put them in the correct folder.


6) PHP field with views

Believe it or not.. one can not use a date field for dates before 1900. Day one is 1/1/1900. Before that there was the big bang according Drupal...(seems to be a php problem) I created a workaround to deal with this problem.

See the birthdates of some painters. I made a view that shows the dates and sorts them correctly. I can even generate a view field that shows a birthday.


You need three separate fields. Day, month and year. 

With a computed field we can make a field that looks like a date field, but is not one.. You can not sort on it.


the code..

For sorting i create another field. Counting the days from 1/1/0000 (you can change them if you need to deal with Greeks and romans... LOL) Mind the avarage days in a year and month.

In the view i use now a PHP field:

With php one can now generate everething you need. Here there is a birthday anouncement, from 2 days before the birthday. PHP in views is not saved into the database. It is an 'ad hoc' value.


7) Iframes

You can capture content from every site you want and add them to your content. As this method is depreciated and even blocked bij some browsers like Chrome. I only mention this possibility but i do not recommend it. You can overrule the safety settings on the server, but is stays not done...

8) Devel Generate

This module comes with the Devel module:

One can add dummy content.


Choose your content type and do the settings.


The result... Content types with images, taxonmy, reference fields... Everething is filled with content.


Lorem ipsum content.
9) Rules

With rules one can add content automatically. On this moment Rules is not user friendly enough to do this.

10) Feeds

CVS import not ready yet. Still waiting..

11) Node Export

Yep... not yet in Drupal 8.

12) VBO

Views Bulk Operations is built in in Drupal 8 core. One can publish, depublish, delete,... content, but not change content.

This module will change that: Bulk Update Fields ( Not ready yet...

13) Views

With Viewfield or EVA, content can be created in a node.