Merge pull request #13097 from codescientist703/add-image-card

feat: Added image field to the section_with_cards template
This commit is contained in:
mergify[bot] 2021-06-22 09:58:12 +00:00 committed by GitHub
commit 9db059c580
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 64 additions and 3 deletions

View file

@ -1,4 +1,4 @@
{%- macro card(title, content, url) -%}
{%- macro card(title, content, url, image) -%}
{%- set col_classes = resolve_class({
'col-12 col-sm-6 col-lg-3': card_size == 'Small',
'col-12 col-sm-6 col-lg-4': card_size == 'Medium',
@ -11,6 +11,12 @@
}) -%}
<div class="mt-6 {{ col_classes }}">
<div class="card {{ card_classes }} h-100">
{%- if image -%}
{{ frappe.render_template('templates/includes/image_with_blur.html', {
"src": image,
"class": ["card-img-top"]
}) }}
{%- endif -%}
<div class="card-body">
<h3 class="card-title">{{ title or '' }}</h3>
<p class="card-text">{{ content or '' }}</p>
@ -34,8 +40,9 @@
{%- set title = values['card_' + index + '_title'] -%}
{%- set content = values['card_' + index + '_content'] -%}
{%- set url = values['card_' + index + '_url'] -%}
{%- set image = values['card_' + index + '_image'] -%}
{%- if title -%}
{{ card(title, content, url) }}
{{ card(title, content, url, image) }}
{%- endif -%}
{%- endfor -%}
</div>

View file

@ -41,6 +41,12 @@
"label": "Content",
"reqd": 0
},
{
"fieldname": "card_1_image",
"fieldtype": "Attach Image",
"label": "Image",
"reqd": 0
},
{
"fieldname": "card_1_url",
"fieldtype": "Data",
@ -65,6 +71,12 @@
"label": "Content",
"reqd": 0
},
{
"fieldname": "card_2_image",
"fieldtype": "Attach Image",
"label": "Image",
"reqd": 0
},
{
"fieldname": "card_2_url",
"fieldtype": "Data",
@ -89,6 +101,12 @@
"label": "Content",
"reqd": 0
},
{
"fieldname": "card_3_image",
"fieldtype": "Attach Image",
"label": "Image",
"reqd": 0
},
{
"fieldname": "card_3_url",
"fieldtype": "Data",
@ -113,6 +131,12 @@
"label": "Content",
"reqd": 0
},
{
"fieldname": "card_4_image",
"fieldtype": "Attach Image",
"label": "Image",
"reqd": 0
},
{
"fieldname": "card_4_url",
"fieldtype": "Data",
@ -137,6 +161,12 @@
"label": "Content",
"reqd": 0
},
{
"fieldname": "card_5_image",
"fieldtype": "Attach Image",
"label": "Image",
"reqd": 0
},
{
"fieldname": "card_5_url",
"fieldtype": "Data",
@ -161,6 +191,12 @@
"label": "Content",
"reqd": 0
},
{
"fieldname": "card_6_image",
"fieldtype": "Attach Image",
"label": "Image",
"reqd": 0
},
{
"fieldname": "card_6_url",
"fieldtype": "Data",
@ -185,6 +221,12 @@
"label": "Content",
"reqd": 0
},
{
"fieldname": "card_7_image",
"fieldtype": "Attach Image",
"label": "Image",
"reqd": 0
},
{
"fieldname": "card_7_url",
"fieldtype": "Data",
@ -209,6 +251,12 @@
"label": "Content",
"reqd": 0
},
{
"fieldname": "card_8_image",
"fieldtype": "Attach Image",
"label": "Image",
"reqd": 0
},
{
"fieldname": "card_8_url",
"fieldtype": "Data",
@ -233,6 +281,12 @@
"label": "Content",
"reqd": 0
},
{
"fieldname": "card_9_image",
"fieldtype": "Attach Image",
"label": "Image",
"reqd": 0
},
{
"fieldname": "card_9_url",
"fieldtype": "Data",
@ -241,7 +295,7 @@
}
],
"idx": 0,
"modified": "2020-10-26 17:42:53.356024",
"modified": "2021-05-03 13:26:34.470232",
"modified_by": "Administrator",
"module": "Website",
"name": "Section with Cards",