Content Import
A simple Drupal module to import content from CSV files into any content type with support for various field types and automatic entity creation.
contentimport
インストール
composer require 'drupal/contentimport:^10.0'
概要
Content Importは、CSVファイルからコンテンツの一括作成・更新を可能にするシンプルなモジュールです。使いやすい管理インターフェースを提供し、コンテンツタイプの選択、新規作成か既存コンテンツの更新かの選択、そしてインポート用CSVファイルのアップロードが可能です。
このモジュールは、画像、エンティティ参照(タクソノミーターム、ユーザー、ノード)、テキストフィールド、日時フィールド、真偽値フィールド、Geolocationフィールド、Geofield、リストフィールドなど、幅広いフィールドタイプに対応しています。主要な機能の一つとして、ボキャブラリー、タクソノミーターム、ユーザーがシステムに存在しない場合に自動作成する機能があり、インポートプロセスをシームレスにします。
インポート処理は進捗表示付きのバッチ操作として実行され、トラブルシューティング用の詳細なログがログファイルに記録されます。サンプルCSVファイル生成機能により、選択したコンテンツタイプに必要な形式を確認できます。
Features
- CSVファイルから任意のDrupalコンテンツタイプにコンテンツをインポート
- ノードIDに基づいて新規コンテンツの作成または既存コンテンツの更新が可能
- 事前にアップロードした画像からファイルエンティティを自動作成する画像フィールド対応
- ボキャブラリーとタームを自動作成するタクソノミータームのエンティティ参照処理
- 存在しない場合にユーザーアカウントを自動作成するユーザーのエンティティ参照処理
- タイトルによるコンテンツノードのエンティティ参照処理
- Full HTMLフォーマットでのテキストフィールド(text、text_long、text_with_summary)対応
- 柔軟な日付フォーマット解析による日付・タイムスタンプフィールド対応
- 複数の真値(On/Yes/on/yes)に対応した真偽値フィールドサポート
- 単一および複数の座標値に対応したGeolocationフィールドサポート
- WKTポイント生成による地理データのGeofield連携
- カンマ区切り値によるリスト(文字列)フィールド対応
- SEOフレンドリーなURLのためのURLパスエイリアス対応
- ユーザー名による作成者の割り当て
- 大規模インポート用の進捗インジケーター付きバッチ処理
- sites/default/files/contentimportlog.txtへのインポートログ出力
- 選択したコンテンツタイプとインポートモードに基づくサンプルCSVファイルの自動生成
- langcodeフィールドによる多言語対応
Use Cases
Bulk Content Migration from External System
Export content from an external CMS or database as CSV, map columns to Drupal field machine names, upload images to the designated folder, and import all content in one batch operation. The module automatically creates taxonomy terms and user accounts as needed.
Regular Content Updates from Spreadsheet
Maintain content in a spreadsheet (Excel, Google Sheets), export as CSV, and use the 'Update existing content' mode to bulk update nodes by their node ID. Useful for updating product information, event details, or any regularly changing content.
Initial Site Content Population
When building a new Drupal site, prepare all initial content in CSV format and import it in bulk, rather than creating nodes one by one through the admin interface.
Multi-language Content Import
Import content in different languages by specifying the langcode column in the CSV. Each row can have a different language code, enabling bulk creation of translated content.
Taxonomy-heavy Content Import
Import content with complex taxonomy structures. The module automatically creates vocabularies and terms that don't exist, making it easy to import content with new categorizations without pre-creating the taxonomy structure.
Tips
- Always download the sample CSV after selecting content type to see the exact field machine names required
- Use the log file (sites/default/files/contentimportlog.txt) to debug import issues - it shows detailed status for each field
- For boolean fields, use On/Yes/on/yes for true values, and Off/No for false values
- When importing geolocation or geofield data with multiple points, use semicolon (;) to separate coordinate pairs
- The import runs as a batch process, so large imports won't time out
- To reference existing content nodes, use colon-separated titles: title1:title2:title3
- Author assignment requires the 'author' column with username values - the user must already exist
Technical Details
Admin Pages 1
/admin/config/content/contentimport
Main import form to upload CSV files and import content into Drupal. Users select a content type and import mode, then upload a CSV file. The form dynamically generates a sample CSV file showing required column headers for the selected content type.
権限 1
Hooks 1
hook_preprocess_page
Attaches the module's CSS library to the Content Import admin page for custom styling.
Troubleshooting 7
Ensure the sites/default/files/ directory has write permissions for the web server user.
Pre-upload all images to public://<content_type>/images/ folder before importing. Use IMCE module or FTP to upload. The CSV should contain only the filename, not the full path.
Ensure your CSV has 'title' and 'langcode' columns in the first row. These are mandatory for creating new content.
When using 'Update existing content' mode, ensure the nodeid values in CSV correspond to actual existing nodes in Drupal.
For fields with multiple vocabulary targets, use the format 'vocabulary:term1,term2'. For single vocabulary targets, you can omit the vocabulary name.
Use m/d/Y h:m:i format for datetime values or m/d/y for date-only values.
Provide email addresses in the CSV. The module looks up users by email, and creates new user accounts if not found.
Security Notes 3
- The module requires 'administer site configuration' permission, limiting access to trusted administrators
- User accounts created automatically during import are activated immediately - review imported users if importing untrusted data
- CSV file validation only checks file extension - ensure CSV files are from trusted sources before import