X

How to test your Content Types with Devel module in Drupal 8

When you are creating a new Drupal site, you need to take into consideration many variations and try to plan very well the content and its structure. One of the most important elements in all this process is testing your content.

Imagine this: you’ve organized your content types and now you want to start planning how that content would look like globally. But at the same time, you know that this content is not yet available or is not very clear, which leads you to think that you must imitate in some way how it will be shown to the end-user.

How to do that? Do you want to work with real content? This would become a tedious process and you would spend a lot of time changing fields and content types unnecessarily.

So the best way to handle that is through some modules that allow us to mimic content for our purposes. What module can do that? Devel Generate Content is the answer. Devel is a very practical module that contains several tools that make Drupal development easier, simplifying repetitive tasks in a simple and agile way.

Devel comes with a module called Devel_Generate, a very effective function that creates dummy content with text and even colored blocks that serve as placeholders for real images. Let’s see how we can use the module to test our content types:

Installing the module and configuring it

Devel Generate is built into the Devel module, so you will have to install it. Once this is done, enable the option corresponding to the module you want to use.

Then, go to Configuration>Development and search for Generate Content option.

Once there, you will see different options to set and generate the content you prefer. You can choose which Content Type you want to fill with dummy content, how many nodes you want to generate, and even the date you want those nodes to appear in time.

Once you click on the Generate button you can see your content automatically generated by the module if you go to the main site. The content of the text is given in Latin –Lorem Ipsum– and the images -well, their placeholders- are blocks of colors that help to form an idea of ​​the page layout.

Using Drush to generate the content

If you prefer to use the command line with the Drush shell, Devel comes with some very useful commands to generate automatic content. For example, suppose you want to create 20 nodes with a maximum of four comments per node:

drush genc 50 4

Easy, right? With genc -generate content- you can create the content you need and if you want more options, Devel covers you back since it accepts several configurations. For example:

drush genc 50 4 --kill

–kill it’s an option that allows you to delete the previous content before generating the new one. Be careful with this, since even the content that you have already set will be removed.

drush genc 50 4 --types=events, user_groups

–types allow you to specify the content types you have created and fill them with the content you need. If you don’t use it, the genc command will generate the content for articles and pages by default. If you want to know more commands for the Drush shell, visit the Drush commands for Devel.

In conclusion

Devel Content Generator is an effective and fast module that allows you to fill your content types with dummy content, which is very useful when testing them. Please note that the Devel Content Generator comes within the Devel module, so you must install it to enjoy its options. Whether you want to use it from the Drupal user interface or from the console with the Drush shell, Devel is an excellent way of populating your website with content.


Tags: DevelDrupal 8Dummy contentmodule