How does the integration support multiple languages?

It's possible to import content from GatherContent in multiple languages into Drupal. GatherContent supports multiple languages using the multiple content tabs on your Items and Templates. Here's how you can use it:

Drupal 7

1. Install required modules

2. Enable Entity Translation
To activate the language option in your GatherContent field mapping screen, you must enable Entity Translation for fields in your content type.

If you want enable multilingual hierarchy creation you need to enable i18n, i18n menu modules and make menus translatable.

3. Go to manage fields and edit fields
You'll need to edit each field in your content type that you'd like to make translatable.

4. Replace the title property with a title field
Delete the title field and replace the default title field with a field instance. This change allows you to specify the language and have different title fields for each translation. Please also ensure that your corresponding GatherContent language tabs all have a title field. If you don't have title fields in your templates the GatherContent Item name will be used as the title for each translation.

5. Add languages
Add the languages and save the configuration.

6. Visit the mapping screen
You will now see the language option in your mapping screen and you can choose a language for each GatherContent tab. You can also select the 'none' option if you want your content to be language agnostic.

7. Map the fields, save the mappings and import your content
You can now map the fields for each GatherContent tab, save the mappings and import the content.

Drupal 8

1. Enable the Content Translation module
To use content translation in Drupal 8, enable the core 'Content Translation' module.
Follow the instructions on Drupal.org on how to install multiple languages to your website: Install Drupal in another language.

2. Select the content types to translate
Go to Configuration > Content language and translation (admin/config/regional/content-language ) in order to configure translations. On this page select the 'Content' option and select all content types you would like to be translatable.
Here you can see all translatable options for each content type. If you are adding a new field, don't forget to check the 'Users may translate this field' option.

3. Visit the mapping screen
You will now see the language option in your mapping screen and you can choose a language for each GatherContent tab. You can also select the 'none' option if you want your content to be language agnostic.


4. Map the fields, save the mappings and import your content
You can now map the fields for each GatherContent tab, save the mappings and import the content.

How does the integration support importing meta tags?

Our integration supports the import of metadata content. Metadata content on GatherContent is usually stored in a tab within your template or structure. Your metadata content will need to be saved in its own tab in GatherContent to work with the integration. Here's what you need to do to use meta tags with our integration:

1. Install "Metatag" module

For Drupal 8 integration, you will need to add a new field and select the Meta tags field type to your content type right after module installation.

2. View the mappings
You'll now see the type option for each GatherContent tab on your mapping screen. You can now choose if the GatherContent tab is mapped to Content or with Metatag values. If necessary, you can also specify the meta tag language.

Mapping options

Currently, we support the basic meta tag options - title, description, abstract, keywords. The GatherContent fields you want to use for meta tags must be in plain text format.

How does the integration support entity reference mapping?

In the Drupal 8 module, you can map an entity reference field type referencing to taxonomy terms. You can map Radio or Checkbox fields from GatherContent to this field type.

1. Map the fields

2. Select the mapping type
There are three different mapping types:

3.1 Map your translations (optional step for the semi-automatic method)
If you have a configuration similar to this one:

and you selected the semi-automatic mapping type, you will be shown a table where you can map translations for GatherContent options.

3.2 Map your terms and translations (optional step for Manual)
If you have a configuration similar to this one:

and you selected the Manual mapping type, you will be offered a table where you can map taxonomy terms and translations for GatherContent options.

Examples:

If you have a single language site and you map a GatherContent field with options Red, Yellow, Black, there will be three taxonomy terms created with titles Red, Yellow, Black and language not defined.

If you have a multi-language site and you map a GatherContent field with options Red, Yellow, Black to the English language and a GatherContent field with options Rot, Gelb, Schwarz to the German language and you use the automatic mapping type, there will be six taxonomy terms created with titles Red, Yellow, Black, Rot, Gelb, Schwarz, the first three with the language English, the other three with the language German.

If you have a multi-language site and you map a GatherContent field with options Red, Yellow, Black to the English language and a GatherContent field with options Rot, Gelb, Schwarz to the German language and you use the automatic mapping type and you map the Red option to Rot, Yellow option to Gelb, etc., there will be three taxonomy terms created and they will be fully translated.

Automation using Drush

We provide Drush integration for both Drupal 7 and Drupal 8. Drush is a command line tool for Drupal which helps you perform various admin tasks using just a couple of commands in the terminal. You can also integrate this with the GatherContent Drupal module, so you can automatically import content after deploying the new version through your CI tool, amongst other tasks.

You can use the following commands:

  • gathercontent-list-mappings (gc-lm) - Using this command you can find available mappings in Drupal.
  • gathercontent-list-status (gc-ls) - Using this command you can find available statuses in GatherContent for a specific project.

Parameters:

  • project_id - ID of project in GatherContent. You can find this value using drush gathercontent-list-mappings.
  • gathercontent-import (gc-i) - Using this command you can import content into a defined mapping from GatherContent into Drupal.
  • mapping_id - ID of Drupal mapping. You can find this out using drush gathercontent-list-mappings.
  • node_update_method - Method used for updating nodes in Drupal. Allowed values are always_create, update_if_not_changed, always_update. always_update is the predefined value. More about the node update method can be found in this article about importing content.
  • parent_menu_item - Machine name of predefined parent menu item.
  • status_id - ID of GatherContent status. If this parameter is provided, the status will be changed in GatherContent. You can find available values using drush gathercontent-list-status

Extending the module using the API

Drupal 7

Drupal 7 uses a hook system. Our module provides several hooks which you can implement in your module and code for the needed functionality. You can find details on how to implement hooks and about creating a custom module on drupal.org. We provide the opportunity to extend the module using the following hooks:

  • hook_gathercontent_pre_node_save_alter – You can change all node properties and perform various operations with them before the node is saved in Drupal. A node doesn’t have a node ID while calling this hook. Menu items and meta tags aren’t saved/created while calling this hook. For operations requiring a node ID see hook_gathercontent_post_node_save_alter.
  • hook_gathercontent_post_node_save – You can change all node properties and perform various operations with them after the node is saved in Drupal. A node has a node ID while calling this hook. Menu items and meta tags are already saved/created while calling this hook.
  • hook_gathercontent_pre_node_upload_alter – You can change the configuration or node before it’s uploaded to GatherContent.
  • hook_gathercontent_post_node_upload – You can change all node properties and perform various operations with them after the node is uploaded to GatherContent.
  • hook_gathercontent_post_import – You can use this hook to create relations between nodes or create various statistics about imports and updates. You can fetch type of operation from Operation entity.
  • hook_gathercontent_post_upload – You can use this hook to create relations between nodes or create various statistics about uploads. You can fetch the type of operation from Operation entity.

Drupal 8

Drupal 8 uses an event system. Details about how to implement events can be found here. Our module provides the following events:

  • gathercontent.pre_node_save – This event allows modules to perform an action before a new node is saved from GatherContent to Drupal. The event is triggered just before the entity saves. The event listener method receives a DrupalgathercontentEventPreNodeSaveEvent instance.
  • gathercontent.post_node_save – This event allows modules to perform an action after a new node is saved from GatherContent to Drupal. The event is triggered after a menu item creation. The event listener method receives a DrupalgathercontentEventPostNodeSaveEvent instance.
  • gathercontent.pre_node_upload – This event allows modules to perform an action before a node is uploaded from Drupal to GatherContent. The event listener method receives a DrupalgathercontentEventPreNodeUploadEvent instance.
  • gathercontent.post_node_upload – This event allows modules to perform an action after a node is uploaded to GatherContent from Drupal. The event is triggered only after successful upload. The event listener method receives a DrupalgathercontentEventPostNodeSaveEvent instance.
  • gathercontent.post_import – This event allows modules to perform an action after selected nodes are imported from GatherContent to Drupal. The event listener method receives a DrupalgathercontentEventPostImportEvent instance.
  • gathercontent.post_upload – This event allows modules to perform an action after selected nodes are uploaded to GatherContent from Drupal. The event listener method receives a DrupalgathercontentEventPostUploadEvent instance.

Paragraphs Module Support

You can map GatherContent fields to Paragraphs fields the same way you'd map other fields.

NOTE: This feature requires the Paragraphs moduleMake sure the Paragraphs module is installed on your Drupal instance. You can check your installed modules under extend tab.
Location: Admin > Extend (/admin/modules)

1. Create a content type with a paragraph field

  • Create a new paragraph type if you don’t already have one.Location: Admin > Structure > Paragraphs types (/admin/structure/paragraphs_type)
  • Add any supported field types to the paragraph type. The same types of fields are supported as previously.
  • Create a new content type if you don’t already have one.Location: Admin > Structure > Content types (/admin/structure/types)
  • Navigate to the manage fields page of the content type by clicking the 'Manage fields' button.Location: (/admin/structure/types/manage/my_content_type/fields)
  • Add a paragraph field to the content type.

1.1 Click the 'Add field' button.

1.2 Select the Paragraph field type, click 'Save and continue'.

1.3 Set the type of reference to Paragraph, and the allowed values to Unlimited. Click 'Save field settings'.

Ensure that the 'Users may translate this field' checkbox must NOT be enabled.

1.4 At the bottom of the page find your paragraph type and check it. Click 'Save settings'.

2. Create the mapping
Go to Manage Mappings and create a mapping to the content type as you have seen before.
Location: Admin > Configuration > GatherContent > Manage Mappings (/admin/config/gathercontent/mapping)

New mapping options should now be available. You should see the paragraph fields you specified earlier as possible mapping fields, provided that they correlate to the supported GatherContent fields.

You can differentiate paragraph fields from their counterparts based on their longer names. A name looks like this:

1 (bundle: 2) - 3

1: The name of the paragraph field in your content type.
2. The name of the paragraph type.
3. The name of the basic field in your paragraph type.

3. Import, update and upload content
You can import, update and upload items the same way you did before.

Unlimited paragraph support

We support unlimited paragraphs. This means in one mapping you can map multiple GatherContent fields to the same paragraph field.

When we create the paragraph field of the content type we have to explicitly set the allowed number of values as Unlimited.

Go to Manage Mappings, and create a mapping for a GatherContent template you would like to map to the content type with the unlimited paragraph field.

Important: the field of the GatherContent template must be in the order of paragraph instances. If you would like to map 2 text fields and 2 image fields to unlimited paragraphs, you must arrange the GatherContent fields like this:

  • GC Text 1
  • GC Image 1
  • GC Text 2
  • GC Image 2
  • GC Text 1
  • GC Text 2
  • GC Image 1
  • GC Image 2

And NOT any other way, e.g. Nested paragraphs. We do not support nested paragraphs.

Other articles on the Drupal integration:

Did this answer your question?