Rules

This is one where I was waiting for ... and I'm not alone ... A Rule consists of two (or three) parts. The event (when the Rule should be implemented), if necessary, additional conditions (eg only for a specific content type), and what action you want? (a mail, a message, a comment, ...) You can also add 'components' which can then be reused in other Rules. 

The module has existed for some time in Drupal 8 version, but did not work properly. I waited until there came a version that could also include conditions. The possibilities are enormous and I will not discuss all of them. I work out one small example. I will send an email when new content was added of a particular content type.

To be clear .. this is the version where I now work with.

First we start with the trigger. Incredible opportunities. We choose 'when new content was created'.

You now have the option to set additional conditions and provide an action.

We will set an additional condition. We're going to filter by content type.

Switch to Data Selection (important!) And choose node. 

You get something like this. Note the position of the switches. You get a white screen if they are not properly set ...

The content type name is the machine name. You find it in the content type settings.

 

Finally, we set what should happen after the content was created of the content type 'article' .. We choose Send an e-mail.

 

It is obvious that you are getting all the settings for the email.

I also add an additional action. There is therefore a message on the site after I installed new content.

Our settings now looks like this.


Do not forget to save. All settings are set separately, but you should save them all together .. you will see this message as long as you did not do this.

Now we test the rule .. After creating content of the type article, we see this. The message...



And yes .. the mail ...


Rules is widely used and is a very usable module. It is good news for Drupal 8 that she is finally usable, despite the many childhood diseases.

I would point out that there is also an export and import option for Rules with Development 

I export my rule ...


Of course I have removed my mail address. Search for it, below, and enter your own address. You should of course import afterwards.

uuid: 1b9f3dcd-b338-44fd-8584-7888ae3a2d0f
langcode: nl
status: true
dependencies: {  }
id: mail_bij_nieuwe_inhoud
label: 'Mail bij nieuwe inhoud'
events:
  -
    event_name: 'rules_entity_insert:node'
description: ''
tags: {  }
config_version: '3'
expression:
  id: rules_rule
  uuid: ed95c6c8-f320-4a6b-ad2e-41031234ed3e
  conditions:
    id: rules_and
    uuid: 345e952c-3f86-4954-b314-12dc2bfd1bef
    conditions:
      -
        id: rules_condition
        uuid: 06757ab9-4e20-4979-8ab4-386d6cdb6a39
        context_values:
          types:
            - article
        context_mapping:
          node: node
        context_processors:
          types:
            rules_tokens: {  }
        provides_mapping: {  }
        condition_id: rules_node_is_of_type
        negate: false
  actions:
    id: rules_action_set
    uuid: cb31a77f-4774-4e16-8462-c83cf8445055
    actions:
      -
        id: rules_action
        uuid: dbc3034b-ea10-4e4f-b3c7-1ca1a1da1843
        context_values:
          to:
            - vulhierjemailadresin@nep.be
          subject: 'nieuwe inhoud'
          message: 'er werd nieuwe inhoud toegevoegd'
          reply: ''
          language: ''
        context_mapping: {  }
        context_processors:
          to:
            rules_tokens: {  }
          subject:
            rules_tokens: {  }
          message:
            rules_tokens: {  }
          reply:
            rules_tokens: {  }
          language:
            rules_tokens: {  }
        provides_mapping: {  }
        action_id: rules_send_email
      -
        id: rules_action
        uuid: 0a97134f-b87a-416d-8acb-7dfd16aaa1de
        context_values:
          message, "new content was added to the type Article ' 
          type: alert 
          repeat: false 
        context_mapping: {} 
        context_processors: 
          message: 
            rules_tokens: {} 
          type: 
            rules_tokens: {} 
          repeat: 
            rules_tokens: {} 
        provides_mapping: {} 
        action_id: rules_system_message