4

I've been following the instructions and the examples to configure ckanext-scheming extension (ckanext-scheming).

I am able to access by URL to the different schemas (as the example shows) that I've configured. Now I wanted to put these links in the main Dataset page in order to choose the schema of the new dataset before is going to be created.

Does anybody know if the extension does that by configuration? Should I modify the CKAN templates to add different schema buttons to be able to creat each new Dataset type? How do I should to modify the template?

1 Answer 1

2

You can override the template snippets/add_dataset.html if you just want to have multiple add buttons.

Here is what you can do (tested on CKAN 2.8.3):

{# Adds 'Add Dataset' button #}

{% set dataset_type = dataset_type if dataset_type else 'dataset' %}

{#
{% if group %}
    {% link_for _('Add Dataset'), controller='package', action='new', group=group, class_='btn btn-primary', icon='plus-square' %}
{% else %}
    {% link_for _('Add ' + dataset_type.title()), controller='package', action='new', named_route=dataset_type + '_new', class_='btn btn-primary', icon='plus-square' %}
{% endif %}
#}

{# Custom add buttons #}
{% for type in ('dataset', 'state') %}
    {% if group %}
        {% link_for _('Add ' + type.title()), controller='package', action='new', named_route=type + '_new', group=group, class_='btn btn-primary', icon='plus-square' %}
    {% else %}
        {% link_for _('Add ' + type.title()), controller='package', action='new', named_route=type + '_new', class_='btn btn-primary', icon='plus-square' %}
    {% endif %}
{% endfor %}

Otherwise if you want to have a tab for the new dataset type, you should extend the header.html template (see block header_site_navigation_tabs).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.