Use triplets

Store and fetch data using Y triplets.

Y Triplets

[Note: You will need to install the Y module and the PHP YAML extension.]

Making Drupal 7 / YAD7 modules is well-documented. You will need to make an example folder in the modules directory and then create the following files in it:

  • example.module

Making effective use of the Y module requires a third file:


Your YAML configuration files need to be placed in a subdirectory called 'config'.

Within the example/config directory, each subdirectory name corresponds to a large group / type concept called a 'protocol'. Each sub-type of data maintained in a protocol is called an 'api'. And, each grouping of 'api' data is associated with an 'id' identifier. Here is how to make a triplet:

Create a file called example/config/admin/helloworld.yaml with these contents:

  &id helloworld:
      title: Hello World
      description: Say Hi
      page callback: y__render
      page arguments: [ *id , !protocol , render, !module ]
      access arguments: [ access content ]
        '#markup': How's it going?<p>This is the example from <a href="">Drupal 7 Triplets</a>

In your example.module file, put these contents:


use Drupal\Y;

 * Implements hook_menu()
function example_menu() {
  return Y\Y::protocol_get_all('admin', 'menu', 'example');;

Then, clear your caches and you should have a URI on your website at /helloworld