[ckan-dev] CKAN resource labels as hyperlinks

Pedro G Silva pedro.gracio at deimos.com.pt
Fri May 6 10:41:56 UTC 2016


Hi
So I went ahead and did it for you:

templates/snippets/package_item.html

find this for block,
{% for resource in h.dict_list_reduce(package.resources, 'format') %}
...
{%endfor%}


replace all block with

                {% for resource in h.dict_list_reduce(package.resources,
'format') %}
{% for r in package.resources%}
{% if r.format == resource%}
                <li>
                  {#% h.url_for(controller='package', action='read', id=
package.name) %#}
                  <a href="{{ r.url }}" class="label" data-format="{{
resource.lower() }}">{{ resource }}</a>
                </li>

{% endif %}
{% endfor %}
                {% endfor %}


On Thu, May 5, 2016 at 8:47 PM, A Joseph <ai.joseph867 at gmail.com> wrote:

> Thanks Pedro. Do you put the absolute path of each resource in the href?
> Also, is there a way to achieve this for all resources currently cataloged
> using CKAN?
>
> On Thu, May 5, 2016 at 10:59 AM, Pedro G Silva <pedro.gracio at deimos.com.pt
> > wrote:
>
>> templates/package/snippets/resources_list.html, generates the resources,
>> and points to this package/snippets/resource_item.html
>> on the latter, locate
>>   <a class="heading" href="{{ url }}" title="{{ res.name or
>> res.description }}">
>>     {{ h.resource_display_name(res) | truncate(50) }}<span
>> class="format-label" property="dc:format" data-format="{{
>> res.format.lower() or 'data' }}">{{ res.format }}</span>
>>     {{ h.popular('views', res.tracking_summary.total, min=10) }}
>>
>> and change href to your resource. You may need to create a helper to give
>> you the direct link, or maybe there is one already on ckan. HOpe this helps
>>
>> On Thu, May 5, 2016 at 2:57 PM, A Joseph <ai.joseph867 at gmail.com> wrote:
>>
>>> CKAN-dev team,
>>>
>>> I’m trying to customize/configure the CKAN resource labels on the main
>>> dataset page to include a hyperlink to the actual resource. For example,
>>> when I click on the “CSV” label on the datasets page, I would like to be
>>> prompted to download the file, rather than taking me to the dataset
>>> description page. Currently, I have to click on the title, which takes me
>>> to the description page, then click on the download button. Is there a
>>> plugin or some sort of customization I need to do in order to have this
>>> functionality?
>>>
>>> In a nutshell, I'm wondering if I can download the resource from the
>>> main dataset page (e.g. demo.ckan.org/dataset), instead of going the
>>> description page, then clicking explore to download the resource.
>>>
>>> Data.gov (e.g. http://catalog.data.gov/dataset) has the exact
>>> functionality I'm looking for on the main datasets page.
>>>
>>> Let me know if this is a possibility.
>>>
>>> Thank you,
>>>
>>> AJ
>>>
>>> _______________________________________________
>>> 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
>>>
>>>
>>
>>
>> --
>>
>>
>> [image: DEIMOS Engenharia, SA] <http://www.deimos.pt>
>> *Pedro Gracio Silva*
>> Aerospace Systems / Production Center
>>
>> *Av. D. Joao II, Lt 1.17.01, 10 • 1998-023 Lisboa, Portugal*
>> Ph: +351 21 893 3020 • Fax: +351 21 896 9099
>>
>>
>> _______________________________________________
>> 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
>>
>>
>


-- 


[image: DEIMOS Engenharia, SA] <http://www.deimos.pt>
*Pedro Gracio Silva*
Aerospace Systems / Production Center

*Av. D. Joao II, Lt 1.17.01, 10 • 1998-023 Lisboa, Portugal*
Ph: +351 21 893 3020 • Fax: +351 21 896 9099
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20160506/7fadac38/attachment-0003.html>


More information about the ckan-dev mailing list