Recently I was working on a D7 to D8 migration. I was trying to import news items and their taxonomy terms (among many other things). To make things simple I wanted the query results to have (for each node) a single field that contained a comma-separated list of taxonomy terms which I could then explode during the row processing. Using GROUP_CONCAT we can achieve this! Let’s break it down:
The Drupal 7 site has the following structure (focusing on the important bits for this blog post):PHP123-- News Item (news_item) <content type>---- Categories (field_categories) <field collection>------ Audience (field_term_audience) <taxonomy reference; unlimited values>
The migration relies on the d7_node migrate source plugin, which basically queries for nodes of a specific type. The query object looks like this (simplified for this blog post):
I’m working on a site that has a “Statistics” paragraph bundle. The output looks like this:
The specification calls for the content author to be able to choose between a few different visual styles for the header (title), shown as Statistics: 3 Up Feature Ipsum Sit H2 in the screenshot above.
The simplest way to achieve this is to add a field to the paragraph bundle:PHP123456789Name: Header StyleMachine name: field_header_styleType: List (text)Allowed number of values: 1Default value: Visually normalRequired: TRUEAllowed values:small|Visually smallnormal|Visually normal
Note that the key (key|value) needs to work as a css class.