This plugin provides a class to handle .csv files in your templates and methods to create pages and structure entries from a .csv file.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
widgets/csv-handler.createpages add route for page creation Oct 20, 2016 version 0.2, add function to create new csv handler Feb 23, 2017

Kirby CSV Handler

Version 0.2


Use one of the alternatives below.

1. Kirby CLI

If you are using the Kirby CLI, you can install this plugin by running the following commands in your shell:

$ cd path/to/kirby
$ kirby plugin:install texnixe/kirby-csv-handler

2. Clone or download

  • Clone or download this repository.
  • Unzip the archive if needed and rename the folder to kirby-csv-handler.

Make sure that the plugin folder structure looks like this:


3. Git Submodule

If you know your way around Git, you can download this plugin as a submodule:

$ cd path/to/kirby-project
$ git submodule add site/plugins/kirby-csv-handler


Usage in scripts

  1. Create a new CsvHandler object:
$csv = csv($filepath, $parse_header = 'false', $delimiter = ',', $length = 8000);
  1. Create pages or structure field
// create pages
$csv->createPages($parent, $UIDKey, $template = 'default', $update = false);
$csv->createPages('products', 'ArticleNo', $template = 'default');

// create structure field
$csv->createStructure($uri, $field, $append = false);


$parent: path to parent page $UIDKey: Columnname you want to use as Page UID, must be unique $template: template to use for new pages $update: set whether or not to update an existing page with the new data

$uri: path to the page where the structure will be stored $field: name of the structure field $append: set whether or not to append new data, if set to false, all data will be replaced with the new data


The following options can or need to be set in your /site/config/config.php file:

c::set('csv-handler.file.filepath', 'path/to/csv/file');
c::set('csv-handler.file.delimiter', ';');

c::set('', 'a_column_name');
c::set('', false);
c::set('', 'template_name');

c::set('csv-handler.structure.field', 'title');
c::set('csv-handler.structure.append', false);


Required. A valid path to a .csv file.


The delimiter between columns in your .csv file. Default delimiter is a comma (,).

A column name that will be used to create the UIDs of the new pages. If you use a column name that starts with a number, an underscore will be used as a prefix. The entries in this column must be unique, otherwise the new page will not be created, or - if is set to true - another entry with the same value will overwrite the first.

If you want to create subpages from the lines in the .csv file, this options defines if existing pages should be updated with the data from the file. Default is false.

Set the template for the subpages. Default is default.


With this option you can set the field that is used for the structure field entries.


Set this option to true to append all lines from the .csv file to an existing field if this exists. By default, the entries from the structure field will be overwritten with the entries of the .csv file.


The Kirby CSV-Handler Plugin currently provides two routes:


where (:all) is the path to the parent page (in case of subpage creation)/page (in case of structure field).

For example, the URL will create subpages in /content/products, while will create/update the structure field in /content/products.

You must be logged in to use the routes.



Sonja Broda