Download the PHP package teppokoivula/import-tool without Composer
On this page you can find all versions of the php package teppokoivula/import-tool. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download teppokoivula/import-tool
More information about teppokoivula/import-tool
Files in teppokoivula/import-tool
Package import-tool
Short Description General purpose ProcessWire module for importing content via predefined import profiles.
License MPL-2.0
Homepage https://github.com/teppokoivula/ImportTool
Informations about the package import-tool
Import Tool for ProcessWire CMS/CMF
Import Tool is a general purpose helper module for importing content via predefined import profiles. The Import Tool module processes provided import file using configuration provided via a "profile", while the Process Import Tool module provides a simple user interface for running imports.
Currently Import Tool supports importing content from CSV files, but the goal is to have it support more formats via readers that can be bundled with the module or implemented separately and plugged in via the API provided by this module. This feature is planned, but not yet implemented.
Many parts of Import Tool have been derived from the Import Pages CSV module by Ryan Cramer. If you're looking for a more mature import module with extensive GUI options, please check Import Pages CSV out.
WARNING: this module is currently considered an early beta release. Test carefully before installing it on a production site! The API of the module is also still subject to change; accessing it via the GUI is safe, but building upon it is not recommended.
Getting started
1) Install Import Tool. Process Import Tool is installed automatically, a new page is created under the Setup page in Admin, and a permission called "import-tool" is added. 2) Add the "import-tool" permission to user roles that should have access to the Import Tool Admin GUI. 3) Define import profile for your data. Currently this can only be done via $config->ImportTools array:
The profile above can import data from a CSV file with structure like this:
If import file column name is an exact match of a local field name, "field" can be omitted:
The "sanitize" property can be any existing Sanitizer method name, or multiple comma-separated method names (this value gets passed to $sanitizer->sanitize()). If built-in Sanitizer methods are not quite enough, you can also provide a callback:
Args is an array of additional arguments and $args['data']
contains the full data array for current row.
If you need more control over how a field value gets stored and/or processed, you can provide a callback. If provided, this overrides the built-in import page value method:
Note: both field and column are technically optional in case a callback function is provided, since you can disregard them anyway in your callback function. Args is the same as for the sanitize callback, i.e. an array of additional arguments with $args['data']
containing the full data array for current row.
In some cases aforementioned callback cannot be executed right away (e.g. in case repeater items are involved), in which case you can delay the execution to after the page has been saved by returning string "after_save" from the method when Page doesn't yet have an ID:
If page with identical name already exists under same parent, it will be considered a duplicate, in which case the "on_duplicate" behaviour will kick in and make the name unique ("make_unique"), update existing page ("update_existing"), or continue to next item ("continue"). If you want to provide more specific rules for detecting duplicates, you can do this via the "is_duplicate" option:
Note, though, that you should only use the "is_duplicate" option to specify more specific rules. If a duplicate isn't matched, there may be an error when new page is saved.
You can add notes for import profiles. These will be displayed in the Import Tool Admin GUI once you select said import profile:
Import profiles can specify "hooks" array key to hook into predefined parts of the import process (before_import_page, import_page, after_import_page). Here's an example of the hooks syntax:
4) Navigate to the Import Tool page in the Admin, select a profile and file, and hit "Import".
All versions of import-tool with dependencies
processwire/processwire Version >=3.0.200
wireframe-framework/processwire-composer-installer Version ^1.0.0