[ckan-dev] free tags from custom fields

Sam Leitner sam.leitner at gmail.com
Thu May 7 19:02:40 UTC 2015


Hi Nilesh,

The extension docs explicitly describe how to add "vocabulary tags", and I
can follow those successfully to create something analogous to the country
codes, but I'd like to add "normal free tags" (in the language used in the
docs) instead  -- I would like to duplicate the functionality of the Tags
field that is built in to CKAN, but using a new field.

Is the Tags field output what you mean by "free extra tags"?

The form field in my package_metadata_fields.html looks as follows for a
new tag field named subject_matter:
{% set subject_matter_attrs = {'data-module': 'autocomplete',
'data-module-tags': '', 'data-module-source':
'/api/2/util/tag/autocomplete?incomplete=?'} %}
{{ form.input('subject_matter', id='field-subject_matter', label=_('Subject
Matter'), placeholder=_('subject1, subject2'), value=data.subject_matter,
error=errors.subject_matter, classes=['control-full'],
attrs=subject_matter_attrs) }}

I don't follow what "skip the template for updations" means. Are you saying
that I shouldn't even be using the IDatasetForm interface? If what I'm
asking for is as simple as some variation of a schema[...].update(...) I
would be very grateful for a specific example.

Many thanks for your help!
Sam



On Thu, May 7, 2015 at 1:30 PM, Nilesh Khule <nileshkhule7 at gmail.com> wrote:

>
> Sam,
>
> You want the custom fields as free tags follow the steps as per
> documentation
> http://docs.ckan.org/en/latest/extensions/adding-custom-fields.html
>
> If you want those custom fields as *free extra tags skip the template
> from updations - **package_metadata_fields.html*
>
>
>
> On Thu, May 7, 2015 at 7:43 PM, Sam Leitner <sam.leitner at gmail.com> wrote:
>
>> Hi ckan-dev,
>>
>> I would like to add a custom dataset field that creates free tags. What
>> is the best way to do that? Is it possible to do this with some slight
>> change to  _modify_package_schema() and show_package_schema() discussed in
>> the plugin documentation?  Something along the lines of a
>> schema.update({ 'new_tag_field':
>> [tk.get_converter('convert_to_free_tags')] })
>> ?
>>
>> All I've found in the docs related to free tags is this: "To create a new
>> free tag simply add the tag to a package, e.g. using the package_update()
>> function." Further clarification would be hugely helpful.
>>
>> Thanks!
>> Sam
>>
>> _______________________________________________
>> ckan-dev mailing list
>> ckan-dev at lists.okfn.org
>> https://lists.okfn.org/mailman/listinfo/ckan-dev
>> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>>
>>
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20150507/839dfe12/attachment-0003.html>


More information about the ckan-dev mailing list