Content and user migration from a Wordpress, Joomla, Drupal 7 site ... to a Drupal 8 site. The easy way ...

Rating

You transfer a site from another CMS or Drupal Drupal version to 8 with programming. However, this is for many people, a step too far. I like to share my experience in the transfer of a Drupal 7 to 8 Drupal site where I have not programmed anything. (This method is applicable to any CMS since each CMS has an export capability of content)

I suppose, however, that you have made a content type on the new site to receive the content. This is handiwork, but it gives you te possibility to exploit the new Drupal 8 opportunities. With Features you could also transfer content types, but the different versions are not compatible with each other. I als suppose you have a different theme. This tutorial handles only the content transfer.

Principle:

  1. export the data from the old site to a CSV file.
  2. use Feeds and Tamper in the most effective manner.
  3. import into the new site.

First, create an export view in your Drupal 7. You can make use of the data export module, but you can also make a table view and paste them into an Excel file ... Here i have used different types of fields. (Text, taxonomy, boolean, files, images, video, email, data, links, ...)

With images you must display via URL, otherwise you get images in your Excel file .. There is a module (also in Drupal 7)  https://www.drupal.org/project/image_url_formatter  ; When you had previously chosen the image formatter and some image style, you get the URL of the image according to its style.. So choose no style if you want the original image.

For files you choose this formatter

for boolean fields (Yes / No)

For video fields

So it comes down to anything that contains files and links to export them as a link ... (preferably absolute link)

You get an Excel file with all the fields that you have chosen.

Now you have to see if you do not need to change the cell properties. E.g. you see some telephone numbers are shown as mathematical figures. (E + 11)

Set the properties as a number:

Successful..

Also, the boolean fields with Yes / No or 0.1 should be adjusted. At the moment of writing this, the import does not work properly. Everything is being regarded ass Yes, even it s No! No problem. Delete all the 'No'. No information on the import is equals as No.

Also delete the hyperlinks from mail and website fields.

If you want to import systemdates (created, published, changed,...) you need to use the 'primitive notation' of the date field. Be sure to fill in the hours:minutes:seconds

Now is the time to save as CSV.

You will see the CSV file and the separation that is being used. (Here, semi-colon)

Now we make our Feeds and Feeds Tamper ready for import. See the discussions of Feeds and Tamper on this site.

I choose to upload the file.

When mapping choose all the required fields.

In the pictures field there is something special..Ik use UUID here. The image is then importing from the URL directly and put in the folder that you set in your new field. No previous download of the image is needed. This import is happening at an incredible speed. Much faster than using an FTP program. Magic!

This method can also be used for files .. The pdf's, docx, ... are just transferred from one site to another.

In  the Tamper you need to set the multiple fields separation. For me this is a comma followed by a space. You put it this way:

I did not see the video field type Vide Embed (for youtube and vimeo)

On the net one describes how to solve this. In the file below you need to add the line "video_embed_field".

Resolved.

You should do this for every content type. If there is little content you copy and paste .. Otherwise...

For the rest, enjoy .. I import hundreds of nodes ... in one minute..

 

Each node has the imported fields that you can display in the appropriate way.

 

 

Importing users

Feeds can import users, their addresses, roles, .... Not their passwords. This is not provided by default for security reasons.

You can add the following items. Take all items you want in the export on the source site. You can do this by creating a view of the users and add the necessary fields. Copy and paste into Excel => CSV.

 


A whole other story... if you want to import the passwords of users. Normally, users are expected to request a new password. Logical, but if you have hundreds of users, and you want the transition to Drupal 7 => Drupal 8 kept as smooth as possible ... then you need some php.

First you go into the database of the source site doing an export of the data. In Drupal 7 this is the table 'users'. Keep only name and password into your CSV file. The passwords are encrypted. (Hash). The good news is that the encrypted passwords are also useful in th Drupal 8 version!

Create a php page in your target site (Drupal8) and use this example script.

For each user, we have already imported, now link the password. (This is empty at this time.) In Drupal 8 the table changed. The table containing the passwords is now users_field_data instead of users. After running this script you can use the original passwords (without hash) as before.

(---For large numbers of users it is better to do once the csv import and storing data in variables. The loop is then a loop with the variables.--- is more professional...)

<?php

 $value=0;

// enter your own data

$conn = mysqli_connect("localhost","gebruiker","paswoord","database");

if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

$sql = "SELECT * FROM users_field_data";
$result = mysqli_query($conn, $sql);

if (mysqli_num_rows($result) > 0) {
    
  while($row = mysqli_fetch_assoc($result)) {  
    

// start loop in loop

// change this to your PD file on the server

if (($handle = fopen("https://test16.cursistendrupal8.be/temp/userexport.csv", "r")) !== FALSE) {
    while (($data = fgetcsv($handle, 2000, ";")) !== FALSE) {
      
if ($data[0] == $row["name"]){
  

$sql2 = "UPDATE users_field_data SET pass='$data[1]' WHERE name='$data[0]'";

if ($conn->query($sql2) === TRUE) {
    echo "Record updated successfully";
} else {
    echo "Error updating record: " . $conn->error;
}


}

 } 
 }

mysqli_close($conn);

    fclose($handle);
}
?>