Skip to content

Commit

Permalink
Use named_routes to allow package_type linking on search page
Browse files Browse the repository at this point in the history
Thanks to advice from @wardi and @amercader

Note the putting of placeholder text all in one translation call; I'm thinking of English vs. German where verb order is different so the thing has to be translated as a group.
  • Loading branch information
mattfullerton committed Sep 8, 2017
1 parent b9d63b4 commit 69d90f0
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions ckan/templates/package/search.html
Expand Up @@ -4,8 +4,7 @@
{% block subtitle %}{{ _("Datasets") }}{% endblock %}

{% block breadcrumb_content %}
{% set type_text = dataset_type.title() %}
<li class="active"><a href="{{ dataset_type }}">{{ _(type_text) }}</a></li>
<li class="active">{{ h.nav_link(_(dataset_type.title() ~ 's'), controller='package', action='search', named_route=dataset_type ~ '_search', highlight_actions = 'new index') }}</li>
{% endblock %}

{% block primary_content %}
Expand All @@ -14,9 +13,7 @@
{% block page_primary_action %}
{% if h.check_access('package_create') %}
<div class="page_primary_action">
{% set add_type_text = 'Add ' + dataset_type.title() %}
{% set add_link = h.url_for(controller='package', action='new') | replace('dataset', dataset_type) %}
<a href="{{ add_link }}" class="btn btn-primary"><i class="fa fa-plus-square"></i> {{ _(add_type_text) }}</a>
{% link_for _('Add ' ~ dataset_type.title()), controller='package', action='new', named_route=dataset_type ~ '_new', class_='btn btn-primary', icon='plus-square' %}
</div>
{% endif %}
{% endblock %}
Expand All @@ -35,7 +32,7 @@
(_('Last Modified'), 'metadata_modified desc'),
(_('Popular'), 'views_recent desc') if g.tracking_enabled else (false, false) ]
%}
{% snippet 'snippets/search_form.html', form_id='dataset-search-form', type=dataset_type, query=c.q, sorting=sorting, sorting_selected=c.sort_by_selected, count=c.page.item_count, placeholder=_('Search') + ' ' + dataset_type + 's' + '...', facets=facets, show_empty=request.params, error=c.query_error, fields=c.fields %}
{% snippet 'snippets/search_form.html', form_id='dataset-search-form', type=dataset_type, query=c.q, sorting=sorting, sorting_selected=c.sort_by_selected, count=c.page.item_count, placeholder=_('Search ' ~ dataset_type ~ 's') ~ '...', facets=facets, show_empty=request.params, error=c.query_error, fields=c.fields %}
{% endblock %}
{% block package_search_results_list %}
{{ h.snippet('snippets/package_list.html', packages=c.page.items) }}
Expand Down

0 comments on commit 69d90f0

Please sign in to comment.