I am using the Shopify plugin, and it seems to be connected properly. However, I want to display the product list in home.php
, and I’m not sure how to do it. The method I usually use doesn’t work here. Previously, I used the following approach to load the children of a page.
templates/home.php
A
<?php if ($productsPage = page('shopify.products')): ?>
<ul>
<?php foreach ($productsPage->children()->products() as $product): ?>
<li>...</li>
<?php endforeach ?>
</ul>
<?php endif ?>
B
<?php if ($productsPage = page('shopify.products')): ?>
<ul>
<?php foreach($productsPage->products()->toPages() as $product): ?>
<li>...</li>
<?php endforeach ?>
</ul>
<?php endif ?>
blueprints/pages/shopify.products.yml
title: Products
options:
delete: false
changeTemplate: false
changeStatus: true
sections:
products:
headline: Products
type: pages
info: "{{ page.handle }}"
template: shopify.product
blueprints/pages/shopify.product.yml
title: Product
options:
delete: false
changeTitle: false
changeTemplate: false
changeSlug: false
changeStatus: false
tabs:
zeropage:
label: Shopify
icon: image
columns:
- width: 1/1
sections:
shopify:
type: fields
fields:
shopifyTitle:
label: Title
type: text
disabled: true
width: 2/4
shopifyID:
label: ID
type: text
disabled: true
width: 1/4
shopifyHandle:
label: Handle
type: text
disabled: true
width: 1/4
shopifyPrice:
label: Price
type: text
disabled: true
width: 1/4
shopifyCompareAtPrice:
label: Compare At Price
type: text
disabled: true
width: 1/4
shopifyFeaturedImage:
label: Featured
type: structure
fields:
src:
label: URL
type: url
disabled: true
width: 1/2
shopifyDescriptionHTML:
label: Description
type: textarea
disabled: true
shopifyImages:
label: Images
type: structure
fields:
src:
label: URL
type: url
disabled: true
shopifyVariants:
label: Variants
type: structure
fields:
title:
label: Title
type: text
price:
label: Price
type: text
compare_at_price:
label: Compare at price
type: text
inventory_quantity:
label: Inventory
type: text
sku:
label: SKU
type: text
disabled: true
shopifyURL:
label: URL
type: url
disabled: true
shopifyType:
label: Type
type: text
disabled: true
width: 1/2
shopifyVendor:
label: Vendor
type: text
disabled: true
width: 1/2
shopifyTags:
label: Tags
type: tags
separator: ,
disabled: true
typeface:
icon: text
label: Typeface
columns:
- width: 1/2
fields:
typename:
label: Typeface Name
type: text
typedescription:
label: Typeface Description
type: writer
- width: 1/2
fields:
typenamekr:
label: 글자 이름
type: text
typedescriptionkr:
label: 글자 설명
type: writer
- width: 1/1
fields:
typeinfo:
label: Additional information
type: structure
width: 1/1
fields:
title:
label: 링크 제목 Link Title
type: text
btntype:
label: 링크 종류 Link Type
type: radio
default: onebtn
options:
onebtn: 링크 이동 Link
twobtn: 다운로드 파일 Download
urllink:
label: 링크 Link
type: url
when:
btntype: onebtn
coverthree:
label: 파일 File
type: files
layout: cards
template: cover
info: "{{ file.dimensions }}"
uploads: false
image:
ratio: 5/4
cover: true
multiple: false
size: small
when:
btntype: twobtn
designer:
icon: text
label: Designer
columns:
- width: 1/2
fields:
name:
label: Name
type: text
description:
label: Description
type: writer
- width: 1/2
fields:
namekr:
label: 이름
type: text
descriptionkr:
label: 설명
type: writer
- width: 1/1
fields:
sns:
label: SNS
type: structure
width: 1/1
fields:
title:
label: 링크 제목 Link Title
type: text
btntype:
label: 링크 종류 Link Type
type: radio
default: onebtn
options:
onebtn: 링크 이동 Link
twobtn: 다운로드 파일 Download
urllink:
label: 링크 Link
type: url
when:
btntype: onebtn
coverthree:
label: 파일 File
type: files
layout: cards
template: cover
info: "{{ file.dimensions }}"
uploads: false
image:
ratio: 5/4
cover: true
multiple: false
size: small
when:
btntype: twobtn
content:
icon: text
label: Sample
fields:
layout:
label: Layout
type: layout
layouts:
- "1/1"
- "1/2, 1/2"
- "1/3, 1/3, 1/3"
# https://getkirby.com/docs/guide/blueprints/layout#defining-columns
twopage:
label: Files
icon: file
columns:
- width: 1/1
sections:
images:
type: files
layout: cards
template: image
info: "{{ file.dimensions }}"
image:
ratio: 5/4
cover: true
# min: 1
size: small