diff --git a/src/open_inwoner/components/templates/components/Card/CategoryCard.html b/src/open_inwoner/components/templates/components/Card/CategoryCard.html index 3d59183ce7..ed42ea404f 100644 --- a/src/open_inwoner/components/templates/components/Card/CategoryCard.html +++ b/src/open_inwoner/components/templates/components/Card/CategoryCard.html @@ -1,10 +1,33 @@ -{% load card_tags icon_tags link_tags helpers %} +{% load card_tags icon_tags link_tags helpers utils %} -{% render_card title=category href=category.get_absolute_url %} - {% for product in category.products.published %} - {% with category as parent %} - {% get_product_url product as product_url %} - {% link href=product_url icon='arrow_forward' icon_position='before' secondary=True text=product.name %} - {% endwith %} - {% endfor %} -{% endrender_card %} +{# create tag for anchor around card - never use anchors within anchors for valid HTML. #} +{% if category.products.published %} +
+
+ {% if category %} +

+ {{ category }} +

+ {% endif %} + {% for product in category.products.published %} + {% with category as parent %} +
+ {% get_product_url product as product_url %} + {% link href=product_url icon='arrow_forward' icon_position='before' secondary=True text=product.name %} +
+ {% endwith %} + {% endfor %} +
+
+ +{% else %} + +
+ {% if category %} +

+ {{ category }} +

+ {% endif %} +
+
+{% endif %} diff --git a/src/open_inwoner/components/templates/components/Card/RenderCard.html b/src/open_inwoner/components/templates/components/Card/RenderCard.html index d78dc5d405..a1e8b87f45 100644 --- a/src/open_inwoner/components/templates/components/Card/RenderCard.html +++ b/src/open_inwoner/components/templates/components/Card/RenderCard.html @@ -1,23 +1,21 @@ -{% load link_tags %} +{% load utils link_tags %} {# Utilizes same template as Card. #} -
+{% capture as tag %}{{ href|yesno:'a,div'}}{% endcapture %} +{# create tag for anchor around card - never use anchors within anchors for valid HTML. #} +<{{ tag }}{% if href %} href="{{ href }}"{% endif %} title="{{ title }}" aria-label="{{ title }}" class="card{% if compact %} card--compact{% endif %}{% if inline %} card--inline{% endif %}{% if stretch %} card--stretch{% endif %}{% if tinted %} card--tinted{% endif %}{% if type %} card--type-{{ type }}{% endif %}"> {% if src %} - + {{ alt }} - + {% endif %}
{% if title %}

- {% if href %} - {% link href=href text=title %} - {% else %} - {{ title }} - {% endif %} + {{ title }}

{% endif %} {{ contents }}
-
+