[ckan-dev] Proper way to create a link - SOLVED
lucia.espona at wsl.ch
lucia.espona at wsl.ch
Tue Nov 15 09:13:47 UTC 2016
Thanks Matt and Adrià
I had tried to build the url with "url_for" but I was not sure how to pass the parameteres, I see it eas very simple.
I will avoid using c.pkg_dict.xxx and replace it with pkg.xxx as you advice.
Best,
Lucia
_________________________________________________________
Dr. Lucia Espona Pernas
Swiss Federal Institute for Forest, Snow and Landscape Research WSL
Hauptgebäaude Labortrakt (HL C21)
Zürcherstrasse 111
8903 Birmensdorf
Switzerland
+41 44 739 28 71 phone direct
+41 44 739 21 11 reception
www.wsl.ch
-----"ckan-dev" <ckan-dev-bounces at lists.okfn.org> wrote: -----
To: CKAN Development Discussions <ckan-dev at lists.okfn.org>
From: Adrià Mercader
Sent by: "ckan-dev"
Date: 14.11.2016 17:47
Subject: Re: [ckan-dev] Proper way to create a link
Hi Lucia,
Following up on what Matthew said you can use the URL builder on any
route that you register on your own plugins:
<a href="{{ h.url_for('package_export', package_id=pkg.name,
file_format='datacite', extension='xml')}}" class="btn">
Also note that you should avoid using all c.xxx variables as this will
be deprecated in the future.
Hope this helps,
Adrià
On 12 November 2016 at 11:22, Matthew Fullerton
<matt.fullerton at gmail.com> wrote:
> Hi Lucia,
> I think something like this might be a minor improvement:
>
> {% set url = h.url_for(controller='package', action='package_read') %}
> <a href="{{url}}/export/datacite.xml"
> class="btn"><iclass="icon-file-text"></i>{{ _('Get DataCite XML')}}</a>
>
> Best,
> Matt
>
>
> On 11 November 2016 at 16:56, <lucia.espona at wsl.ch> wrote:
>>
>> Dear all,
>>
>> I am working on an extension that converts the CKAN metadata to a DataCite
>> XML (https://github.com/espona/ckanext-package_converter).
>>
>> In this first version the XML can be retrieved in two ways:
>> - Adding "/export/datacite.xml" to the package path, for example:
>> http://www.envidat.ch/dataset/10-16904-2/export/datacite.xml
>> - API call:
>> http://www.envidat.ch/api/action/package_export?id=10-16904-2&format=datacite
>>
>> Now I want to put a button in the package read page that downloads the
>> XML. I did a quick solution that works:
>>
>> <a href="https://webnotes.wsl.ch/dataset/{{c.pkg_dict.get('name')}}/export/datacite.xml"
>> class="btn"><i class="icon-file-text"></i>{{ _('Get DataCite XML')}}</a>
>>
>>
>> Is there a better/cleaner way to do this?
>>
>> Thanks,
>> Lucia
>>
>>
>> _________________________________________________________
>> Dr. Lucia Espona Pernas
>>
>> Swiss Federal Institute for Forest, Snow and Landscape Research WSL
>> Hauptgebäaude Labortrakt (HL C21)
>> Zürcherstrasse 111
>> 8903 Birmensdorf
>> Switzerland
>>
>> +41 44 739 28 71 phone direct
>> +41 44 739 21 11 reception
>>
>> www.wsl.ch
>> _______________________________________________
>> 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
>
_______________________________________________
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/20161115/6d8198ad/attachment-0003.html>
More information about the ckan-dev
mailing list