Skip to main content Skip to secondary navigation
Container ship with exported goods

Exporting Publications from your Drupal 7 Site

Main content start

Here are directions for exporting publications from your Drupal 7 and importing them into your Drupal 8+ site. These directions are for both Biblio and Stanford Publications. 

Prerequisites

  • You must have sufficient privileges on your Drupal 7 site to make a view
  • You must understand how to make Views in Drupal 7
  • You must have a basic understanding of URLs and paths
  • You must understand how to use Google Sheets

Exporting from your Drupal 7 Site

1. Get the target fields

You'll need to know the target fields needed for importing into Drupal 8+ site. 

  1. From your D9 site go to /admin/structure/migrate/manage/default/migrations/stanford_publications/csv-upload
  2. And click on Empty CSV template 
  3. Open the CSV in Google Sheets.
    Note: I found that neither Excel and Number on MacOS would export the CSV properly. Google Sheets worked without any problems.

2. Create a new view 

On your Drupal 7 site:

1. Add the view
Structure > Views > Add new view

  1. Check Create a page 
  2. Check "Create a page" 
  3. View name: Publications Export or similar (the machine readable name will be the path by default)
  4. For Publications features: Show Content of type Publication
    1. For Biblio: set the type to get Biblio entries
  5.  Set the Display Format to Table
  6. Set Items to display:
    1. If you have less than 1000 publications, you can probably enter 0 for all publications
    2. If you have many more publications, you’ll probably want to break it into pages.
  7. You can probably use the defaults for remaining fields.
  8. Select Continue & Edit to add more fields to your view.
Field/Value table for Add View Configuration
Field Value
View name Publications Export (or something you similar)
Show Content
of type Publications
Display format Table
Items to display 0 (this means all the items)

3. Configure the new view

Next, you'll want to add new fields and edit the view with the following settings. This step will be the bulk of the work. Doing it perfectly does save time, but there is an opportunity to check your work and make corrections later.

  • Having a unique identifier will let you import updates later. Typically you'll want to use the NID (Node ID) as a unique identifier. If you have another field that was unique per publication, you can use that instead.
  • For each field, the ‘Create a label’ should be checked, and the Label should correspond to the Column title in the sample spreadsheet.
    Tip: You can fix the labels later in the CSV.
    • For example: For Nid - the label should read “id (ID)”
  • All columns must be in the same order as the CSV file.
  • Sort can be set however suits you best

Configuring the view labels and fields for Stanford Publications:

Field/Value table for configuring the view
 

D9 CSV Label

D7 Field

Configuration notes

a

ID

Content: Nid

Must be unique

b

citationType

Global: Custom Text

Types are limited to:

  • Article Newspaper/Magazine
  •  Book
  •  Journal Article
  •  Other
  •  Thesis

You might assign a default value such as “Journal Article” or what’s most common in the Text Field. This can be changed in the CSV.

Important: Under ‘No Results Behavior’, if the field will be blank, put ‘Other’ so it corresponds to the new Publication type. If there is no data and nothing to import, it will ignore your publication entirely.

c

Title

Title

Uncheck Link this field to the original piece of content

d

Subtitle

Global: Custom Text

Placeholder. There’s no D7 equivalent.

e

Authors

Author

Formatter: Plain text

f

pubPlace

Global: Custom Text

Placeholder. There’s no D7 equivalent.

g

publisher

Publisher

Formatter: Default?

h

volume

Global: Custom Text

Placeholder. There’s no D7 equivalent.

i

Issue

Global: Custom Text

Placeholder. There’s no D7 equivalent.

j

Edition

Global: Custom Text

Placeholder. There’s no D7 equivalent.

k

Page

Global: Custom Text

Placeholder. There’s no D7 equivalent.

l

Month

Global: Custom Text
or ??

Global: Custom Text if there’s no D7 equivalent.
or 
use Custom date format

m

Day

Global: Custom Text
or ??

Global: Custom Text if there’s no D7 equivalent.
or 
use Custom date format

n

Year

Year

Formatter: Date and Time

Choose how users view dates and times: Custom

Custom date format: Y

o

doi

Global: Custom Text
or field with DOI 

Global: Custom Text if there’s no D7 equivalent.
Or map the link field to DOI field

p

Url (External Source URL)

Content: link
stanford_publication

Formatter: URL, as plain text

q

image

Global: Custom Text

Images won't export and import via CSV. This will need to be done separately.

r

topics

Content: Type
stanford_publication

formatter Plain Text

You may want to choose the “|” as the separator

s

body

Content: body

Formatter: Default

Note: that this approach simply exports the text. Formatting and links are lost.

t

ctaUrl

Global: Custom Text

Placeholder. There’s no D7 equivalent.

u

ctaTitle

Global: Custom Text

Placeholder. There’s no D7 equivalent.

v

ctaGenre

Global: Custom Text

This shows only for Thesis as Type of Dissertation

Configuring the view for Biblio

  • Filter to make sure you are getting only Biblio entries
  • Make sure you uncheck the box that says “Use label specific to biblio type”
  • For the Authors field
    • make sure you select “All categories” for Category of Author
    • Select First name first for Name order
    • Uncheck the box that shortens given names (unless you prefer not to)
    • Change the author separator to a “|”
  • Biblio does not have separate day, month, and year dates. You can use the same field for all. In cases where the date is more than a year, expect to spend a lot of time cleaning this up
  • There is no image URL field in Biblio. Use Global: Custom Text as a placeholder column for the image. 
  • For the Keywords field in Biblio, choose the “|” as the separator
Field configuration for exporting biblio publications from a view

 

4. Make adjustments

  • You can preview your work by looking at the preview field OR by going to the path you specified in your views settings. For example: 
    https://[sitename].stanford.edu/publications-export
  • Double Check the data. Not everyone does great data entry! For example, in one case someone had used the Source field for the publication year. You may need to consult the publications to see what fields they used in each case

5. Add the table into a Google Sheet

Note: Use Google Sheets. Neither Numbers or Excel exported the CSV properly. 

Copy and paste

  • Make a new Google Sheet
  • Go to the page you created with your view. You should see a giant table of your publications
  • Starting with the top left corner of the table, select everything all the way down to the bottom right corner
  • Paste this table into your Google Sheet (Note: if everything appears in a single row, you somehow didn’t get the entire table. Go back and try to select and copy from your view page again.)
  • You should now see a table that matches the view table on your D7 site.
  • Now add in any columns that you didn’t export. (On the example sheet, those have a non-bold header)

Alternative path

  • Enable the module Views Data Export, which is available on Stanford Sites Drupal 7
  • Add a display to your view of the type “Data Export
  • By default, the display Format should be CSV. The default settings here are fine.
  • Under Data Export settings, choose a path for your CSV file. In this example, I chose “pubexport.csv”
  • Under "Pager" settings, update the "items to display" to "Display all items" 
  • Download the csv file by going to https://[yoursitename].stanford.edu/pubexport.csv
  • A csv file should be downloaded onto your computer
  • You can now open that file in Google Sheets if you’d like to check your work (see the next step!) or you can skip straight to “Import your work.” 

Check your results

  • If you find weird characters in your CSV file after import, the best way to fix these is to do a find/replace in Google Sheets.

6. Import into your new site

  1. Go to the Upload page on your Drupal 8+ site at https://<sitename>.stanford.edu/admin/structure/migrate/manage/default/migrations/stanford_publications/csv-upload
    as described in the User Guide (https://userguide.sites.stanford.edu/build-and-design/publications/publications-importer-experimental)
  2. Select your CSV file for upload
  3. Click Save & Import
  4. Check that it worked!

Note: if you want to fix things and try again, you can bulk delete the publications and start over OR you can rely on the unique ID to help you update the existing records

7. Get the images

Export images

On the D7 site:

  1. turn on the File Entity module (if it isn't already on,)
  2. Navigate to /admin/content/file,
  3. select everything
  4. click "archive."

This will give you a zip of all their PDFs, images, etc.

Import images

On your Drupal 8+ site

  1. Go to All content > All Media > Add Media
  2. Click on Upload File(s)
  3. Either drag and drop your images local computer, or click on Select Files to choose file from your local computer

Add images to publications

This is a bit tedious. For each publication on your new site, find the image in the Media Library that goes with that publication and add it to the publication.