Planet Drupal

Subscribe to Planet Drupal feed
Drupal.org - aggregated feeds in category Planet Drupal
Updated: 10 hours 43 min ago

Specbee: How To Improve Your Development Workflow - An Approach For Better Efficiency

27 August 2018 - 5:59am

How can developers improve the quality of Development by saving time and effort? In this blog, we discuss about the advantages of efficiently using git and by setting the local environment with Lando or Docker instead of the traditional way.

Categories: Drupal

OpenSense Labs: HowTo: Migrate Content from a CSV file to Drupal 8

27 August 2018 - 5:51am
HowTo: Migrate Content from a CSV file to Drupal 8 Gaurav Mon, 08/27/2018 - 18:21

Upgrading involves shifting lots of files and content from one site to another. Although there are a number of modules to help you migrate to and in Drupal, the process can turn out to be messy. 


Migration of content can have various meanings and the scope of file formats - JSON, CSV, spreadsheet or text files - is also important.

In this article, I am going to demonstrate the migration of taxonomy terms using CSV files to Drupal 8. Thanks to Drupal’s entity-based system, the process of migration is more or less similar for all kinds of entities. Once you master the migration process, you can easily migrate nodes, users, vocabularies and custom entity data.

You can use various modules for migration to Drupal 8

Drupal 8 core provides the Migrate and Migrate Drupal modules which are useful when migrating from Drupal 6/7 to Drupal 8. In other cases, we have to use contributed modules. Install Migrate Plus which provides a powerful API for data migration from CSV and spreadsheets and is one of the foremost dependencies.

We will take a sample use case of the States list where our taxonomy terms will be the States' list. Let's get started.

Read Upgrade to Drupal 8 | Complete Migration Guide

Installation
  • Download the Migrate Source CSV module and install it on your Drupal website. Use Composer to install all the required dependencies.
composer require ‘drupal/migrate_source_csv:^2.2’
  • Enable the module from Extend menu or Drush Command. 
$ drush en migrate_tools $ drush en migrate_source_csv
  • In this example, I am going to migrate the USA States data. I have already created a vocabulary as ‘States’ with fields Name (Default Field in Taxonomy) and State Code (the abbreviation).
     
  • Prepare a CSV file with Headers containing Fields Name and also add an ID field which will act as a unique identifier and can also be later used in migration in case States vocabulary is used by a reference field. Here is the CSV which I have prepared:
     

    ID

    State

    Abbreviation

    1

    Alabama

    AL

    2

    Alaska

    AK

    3

    Arizona

    AZ

    4

    California

    CA

    5

    Colorado

    CO

    and so on.
     
  • Next and the most important step is to write a migration plugin which is a .yml file describing the mapping between data in CSV and Drupal Fields. 

    Here is the migration plugin which I wrote: id: state_data class: null field_plugin_method: null cck_plugin_method: null migration_tags: - 'USA States' migration_group: default label: 'State migration from CSV' source: plugin: csv path: 'public://USAStates.csv' header_row_count: 1 keys: - id column_names: - id: id - title: state - abbreviation: abbreviation process: name: title field_abbreviation: abbreviation destination: plugin: 'entity:taxonomy_term' default_bundle: state migration_dependencies: null I have provided a Migration ‘id’, ‘class’, ‘field_plugin_method’, ‘cck_plugin_method’. ID acts as a unique identifier for the migration process. Rest of keys mentioned above aren’t needed in this migration.

    Other keys and their importance:
     
    • Migration Tags: These are displayed as a description in migration UI.
       
    • Migration Group: It is an important field in case you have various migration processes. I have used the default group for this migration.
       
    • Label: It is also a description field for the migration displayed in Migration UI.
       
    • Source: It is the important key and we provide type of plugin i.e CSV in our case, path of our CSV file, Header Row Count so that migration API is able to distinguish between Data and Labels, Key i.e the unique identifier in CSV file.

      Next, we have a mapping of columns in CSV with temporary identifiers which are used in process key. Process key defines mapping with Drupal field and a temporary identifier in format (Drupal Field: Temporary Identifier).
       
    • Destination: This key is used to provide the target entity and bundle if any. Since we are migrating terms data so I have used ‘taxonomy_term’ and bundle ‘state’.
       
  • Once you have created the plugin, it is time to inform the system about. Migration plugin can be imported via Single Config Import menu (/admin/config/development/configuration/single/import). Paste your plugin with config type ‘Migration’ and press import.
  • Once you have imported the migration plugin you can run the migration process via UI or drush command.

    UI: Go to /admin/structure/migrate and under the list migration menu, you can execute the migration process for the respective migration type.

    Drush: Enter the drush command ‘drush mi state_data’ where state_data is the unique ID of the state's migration.

  • Once the migration process is complete all the Terms are created and the abbreviation field is populated as well.

  • You can rollback, resume and stop migration from Migration UI as well in case something goes wrong or you have some extra data to migrate later on. 

  • In case you have to do any changes in Plugin after importing it, you will first have to export its config file from (admin/config/development/configuration/single/export) and then import it again. 
     

    And it is done!

That is how you can migrate content from a CSV file to Drupal 8. Drop a comment below in case of a query. 

blog banner blog image Blog Type Tech Is it a good read ? On
Categories: Drupal

OSTraining: How to Set Up Dropdown Menus in Drupal 8

27 August 2018 - 4:46am

A few years ago, we published a very popular post called "How to Create Dropdown Menus in Drupal".

That post focused on Drupal 7, and some things have changed in Drupal 8.

Here's an updated explanation of how to set up dropdown menus for a Drupal 8 site.

Categories: Drupal

Ramsalt Lab: Expo.se - Magazine started by the famous author Stieg Larsson - nominated for two publishing awards

27 August 2018 - 4:22am
  • Expo just got nominated for two prestigious publishing awards in Sweden, best magazine and best magazine website. The winners will be announced 7th of November 2018 in Stocholm where Ramsalt Lab will be present. We are very excited for this news and have decided to share with you the secrets behind building Expo.se on Drupal. So stay tuned for more the following days. 

    Short about the Expo 

    Expo is a Swedish anti-racist magazine started in 1995 by Stieg Larsson, also known as the author of the Millennium novel series, where the inspiration comes from Expo. Expo magazine is issued by the non-profit Expo Foundation. The magazine contains investigative journalism focused on nationalist, racist, anti-democratic, anti-semitic, and far-right movements and organisations. Expo became widely known in Sweden after 1996 following a string of threats and attacks directed against companies printing and selling the magazine, and organisations supporting it. The magazine is headquartered in Stockholm. More about Expo on Wikipedia

    Have a look at the website on Expo.se

    planetdrupal
    Categories: Drupal

    OpenSense Labs: In the Pursuit of Headless with Contenta

    26 August 2018 - 10:53pm
    In the Pursuit of Headless with Contenta Akshita Mon, 08/27/2018 - 11:23 When I first heard of Contenta (not aware of what it was), I was perplexed as to how could anyone use such a funny name for a tech product? Was it so good that it made people happy and content with it?  What Is Contenta?  

    With Drupal 8’s rise as the headless platform, one of the inferences of the DrupalCon Baltimore was to make the headless transition smoother. And this is how Contenta was born.

    Categories: Drupal

    Droptica: 13 lectures and presentations worth seeing at DrupalEurope 2018

    26 August 2018 - 10:33pm
    DrupalEurope is this year’s largest European conference devoted to Drupal. In previous years, each edition of the conference (formerly known as DrupalCon) was attended by about 2000 participants. We already know the programme of the conference with 162 hours of lectures over the course of three days! I decided to go through the programme and make a list of 13 lectures that I think are worth seeing. 1. Driesnote On Wednesday, 12th of September at 9:00 a.m. Dries Buytaert will talk about the status of Drupal 8. This is a lecture I always attend at DrupalCon. You can learn interesting things about Drupal usage statistics and the system development plans. It's definitely worth attending if you want to know what will happen with Drupal in the coming months.
    Categories: Drupal

    ActiveLAMP: Deploying Docker containers - Introduction to Kubernetes

    26 August 2018 - 6:44pm

    We are going to take the Drupal image that I created from my last post “Creating a deployable Docker image with Jenkins” and deploy it. You can find the image that we created last time up on Docker Hub, that is where we pushed the image last time. You have several options on how to deploy Docker images to production, whether that be manually, using a service like AWS ECS, or OpenShift, etc… Today, I’m going to walk you through a deployment process using Kubernetes also known as simply k8s.

    Read more...
    Categories: Drupal

    Hook 42: August Accessibility (A11Y) Talks - A11Y Meetups, Camps, and Beyond

    26 August 2018 - 11:26am

    Dennis Deacon has been involved in digital accessibility for the past four years, most recently as an Accessibility Engineer with The Paciello Group. He’s led the Chicago Digital Accessibility & Inclusive Design Meetup since December 2014. He is organizing Chicago's first Accessibility Camp later this year. And, he leads the curation of the 24 Accessibility article series.

    Dennis Deacon spoke about starting the Chicago Digital Accessibility and Inclusive Design Meetup. He spoke about digital accessibility but focused on delivering the most accessible events possible.

    Categories: Drupal

    Zhilevan Blog: Drupal Global Services, How to use global services in Drupal 8

    25 August 2018 - 10:08am
    One of the significant improvements of Drupal 8 that got me excited was the services & dependency-injection throughout the entire Drupal system. From aspects like routing, templating, managing configuration, querying and persisting data, you name it everything is done with services. it's fantastic because it grants developers a level of flexibility in extending Drupal that is far greater than what Drupal 7 was able to. by using well-disposed structure developers get ride of ravioli coding.
    Categories: Drupal

    Ashday's Digital Ecosystem and Development Tips: Drupal Module Spotlight: Reroute Email

    24 August 2018 - 2:00pm
     

    “Excuse me, Mr./Mrs. Client, I’m so sorry but I accidentally just sent your 3000 users a fake purchase email receipt when I was testing.”

    Ugh.

    Big complex systems are a lot to keep track of, especially when it comes to email. There are emails for resetting passwords, emails for new users, email receipts, email notifications for workflows, etc, and it’s frankly a little terrifying to rely on yourself to remember all the implications of what’s going on when working on local environments, or test servers or anywhere but production. All you have to do to experience this pain is trigger an accidental FAKE email send to REAL people. 

    That’s where modules like today’s spotlight comes in. 

    Categories: Drupal

    Pages