Install via pip:
pip install ckanext-create-typed-package
Enable the plugin:
ckan.plugins = create_typed_package
Note: Extension requires pre-configured custom dataset types (via ckanext-scheming or CKAN type registry).
Example with ckanext-scheming:
pip install ckanext-scheming
ckan.plugins = scheming_datasets create_typed_package
scheming.dataset_schemas = path/to/schema1.yaml path/to/schema2.yaml
Configuration options:
Build type list using ckanext-scheming API instead of CKAN’s package_type registry (optional, default: false)
create_typed_package.use_scheming = true
Additional types not automatically added to the list (optional, default: [])
create_typed_package.additional_types = custom_type another_type
Exclude specific types from available list (optional, default: [])
create_typed_package.exclude_types = unwanted_type another_unwanted
Use separate page instead of modal for type selection (optional, default: false)
create_typed_package.use_separate_route = true
Replace ‘Add Dataset’ button with link to type selection (requires use_separate_route=true, optional, default: false)
create_typed_package.replace_dataset_button = true
Custom URL for type selector page (optional, default: /dataset/select-type)
create_typed_package.route_path = /create-package/select-type
Custom labels for dataset types (optional, default: tk._(type_machine_name))
create_typed_package.label_for. = Human Readable Label
create_typed_package.label_for.dataset = Publication
Dynamic type options (advanced):
Implement IAction interface and register chained action ‘ctp_list_types’ to provide context-dependent type lists:
import ckan.plugins.toolkit as tk
from ckan.types import Context
@tk.chained_action
@tk.side_effect_free
def ctp_list_types(next_action, context: Context, data_dict):
if tk.get_endpoint() == ("organization", "read"):
organization_id = tk.request.view_args.id
allowed_types = ... # compute types for organization
return [
{"name": item.VALUE, "label": item.LABEL}
for item in allowed_types
]
return next_action(context, data_dict)
Action must return list of dicts with ‘name’ (machine name) and ‘label’ (human readable).
Behavior:
- If action returns >1 item: modal/page with selector shown
- If action returns exactly 1 item: redirect directly to that type’s form
UI modes:
1. Modal (default): JavaScript-based modal after clicking ‘Add Dataset’
2. Separate page: /dataset/select-type (enable via use_separate_route)
3. Button replacement: Replace original button with selector link (requires use_separate_route)
Requirements:
- Python >= 3.8
- Custom dataset types configured (ckanext-scheming recommended)
- ckantoolkit dependency