avdeb / kirby-avdeb
Show AVDEB products (a creator's shop, a category, a search or a single product) on your Kirby site with your affiliate referral code on every link: KirbyTags, blocks with a live Panel preview, and PHP helpers.
Requires
- php: >=8.1
- getkirby/composer-installer: ^1.2
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Show AVDEB products on your Kirby site (a creator's shop, a category, a search or a single product) with your affiliate referral code on every link.
- Blocks with a live preview: AVDEB products, AVDEB product and AVDEB button blocks for the blocks and layout fields. The Panel shows the real products while you edit.
- KirbyTags:
(avdeb-products: https://avdeb.com/category/stickers/ layout: carousel)in any textarea or Markdown block. - Anywhere else:
{avdeb-products …}tags work in writer fields, text blocks and any HTML your templates output. In PHP:<?= avdeb()->products(['tag' => 'stickers']) ?>. - Four layouts: grid, carousel (scroll-snap with keyboard and arrow buttons), list ("shop the post") and spotlight. Single products render as a horizontal card, a hero or a compact card, with your own badge and note.
- Fits your design: container queries let embeds adapt to the column they sit in. Choose inherit, light, dark or system theme, plus card style, accent colour, radius and image shape. Styles use
:where()(zero specificity), so your CSS always wins, and--avdeb-*custom properties restyle everything. Or useavdeb()->data()for your own markup. - Fast and resilient: products are fetched on the server and kept in Kirby's cache. If AVDEB can't be reached, the last good copy is shown for a week. The stylesheet and the small carousel script load only on pages that show products.
- Honest links: referral links get
rel="sponsored", and an optional affiliate disclosure appears under embeds that carry a code. - Private by default: no third-party scripts, cookies, iframes or tracking. The secret key stays on the server.
Requirements
- Kirby 4, 5 or 6
- PHP 8.1 or later (the
intlextension gives localised prices; without it prices use a simple format)
Installation
With Composer:
composer require avdeb/kirby-avdeb
Or download the latest release and put the folder in site/plugins/avdeb. As a Git submodule:
git submodule add https://github.com/Avdebcom/kirby-avdeb.git site/plugins/avdeb
Configuration
Add your referral code to site/config/config.php:
return [ 'avdeb.products' => [ 'refCode' => 'YOURCODE', ], ];
Or set environment variables instead (AVDEB_REF_CODE, and optionally AVDEB_SECRET_KEY). With a secret key (avdeb_sk_…) your code is added automatically and embeds can show up to 48 products (12 without). Keep the key out of git: read it from the environment, for example 'apiKey' => getenv('AVDEB_SECRET_KEY').
| Option | Default | |
|---|---|---|
refCode |
AVDEB_REF_CODE |
Your referral code, added as ?ref= to every link |
apiKey |
AVDEB_SECRET_KEY |
Secret key (avdeb_sk_…), server only |
layout |
'grid' |
grid, carousel, list, spotlight |
columns |
3 |
1–6 (narrow columns get fewer automatically) |
cardStyle |
'elevated' |
elevated, outline, minimal |
theme |
'site' |
site (inherit your colours and fonts), light, dark, auto |
accentColor |
AVDEB green | Hex colour for buttons and highlights |
radius |
16 |
Corner radius in px (0–32) |
imageRatio |
'square' |
square, portrait, landscape |
ctaLabel |
'View product' |
Button text on cards |
showPrice, showCreator, showBadges |
true |
Card details |
newTab |
false |
Open product links in a new tab |
showDisclosure |
true |
Affiliate disclosure under embeds that carry a code |
disclosureText |
"As an AVDEB affiliate, I earn a commission from qualifying purchases." | |
cacheMinutes |
360 |
How long fetched products stay fresh (5–2880) |
locale |
the current language, else 'en-US' |
Price formatting |
assets |
true |
Add the stylesheet and carousel script to pages with products |
tags |
true |
Replace {avdeb-…} tags in every HTML page |
Each option also works as a single key, for example 'avdeb.products.refCode' => 'YOURCODE'.
Become an AVDEB affiliate
Free to join: 5% commission, 30-day cookie, monthly PayPal payouts in USD ($50 minimum), open worldwide. Apply at avdeb.com/affiliate/apply. After approval, copy your referral code (or create a secret key) in the partner dashboard.
Usage
Blocks
Add the AVDEB blocks to a blocks (or layout) field in your blueprint:
text: type: blocks fieldsets: - heading - text - image - avdeb-products - avdeb-product - avdeb-button
To offer them in every blocks field, list them in the blocks.fieldsets option. The blocks render with $page->text()->toBlocks() like any other block. AVDEB products takes an AVDEB link or search words, a layout, the number of products, a heading and an intro, with display overrides on its second tab.
KirbyTags
In any field you output with ->kirbytext() (or ->kt()), and in Markdown blocks:
(avdeb-products: https://avdeb.com/creators/cleo/ layout: carousel limit: 8 heading: From my shop)
(avdeb-products: https://avdeb.com/category/stickers/ layout: list limit: 3)
(avdeb-products: keychain layout: grid columns: 4)
(avdeb-product: https://avdeb.com/store/custom-qr-code-keychain/ variant: hero badge: Editor's pick note: I use it every day.)
(avdeb-button: /creators/cleo/ label: Visit my shop variant: outline align: center)
The first value is a creator, category or product link (detected automatically) or search words.
(avdeb-products:) attributes: creator, tag, type, q, limit, layout, columns, heading, intro, level, viewall, cardstyle, theme, accent, radius, ratio, buttontext, hideprice, hidecreator, newtab, locale.
(avdeb-product:): variant (horizontal, hero, card), badge, note, plus the display attributes. (avdeb-button:): label, variant (solid, outline, link), align (start, center, end).
Tags in any HTML
Writer fields and text blocks don't run KirbyTags, so the plugin also replaces tags in curly braces anywhere in a page:
{avdeb-products https://avdeb.com/category/stickers/ layout="carousel" limit="8"}
{avdeb-product https://avdeb.com/store/custom-qr-code-keychain/ variant="hero"}
{avdeb-button href="/creators/cleo/" label="Visit my shop"}
A tag alone in a paragraph replaces the whole paragraph. Write {{avdeb-products}} to show a tag as text. For output outside a page (feeds, JSON), use the field methods $page->text()->avdeb() and $page->text()->avdebStrip() (removes the tags).
PHP templates
<?= avdeb()->products(['url' => 'https://avdeb.com/creators/cleo/', 'heading' => 'From my shop']) ?> <?= avdeb()->products(['tag' => 'stickers', 'layout' => 'carousel', 'columns' => 4, 'limit' => 10]) ?> <?= avdeb()->products(['q' => 'keychain', 'layout' => 'list', 'limit' => 3]) ?> <?= avdeb()->product('custom-qr-code-stickers', ['variant' => 'hero', 'badge' => "Editor's pick"]) ?> <?= avdeb()->button(['href' => '/creators/cleo/', 'label' => 'Visit my shop', 'variant' => 'outline']) ?>
Options: url, creator, tag, type, q (leave all empty for the newest products), limit, layout, columns, heading, intro, headingLevel, viewAll, cardStyle, theme, accent, radius, ratio, buttonText, hidePrice, hideCreator, newTab. For a single product: variant, badge, note.
Your own markup
<?php $result = avdeb()->data(['tag' => 'stickers', 'limit' => 4]) ?> <ul> <?php foreach ($result['cards'] as $card): ?> <li><a href="<?= esc($card['href'], 'attr') ?>" rel="<?= $card['rel'] ?>"><img src="<?= esc($card['image'] ?? '', 'attr') ?>" alt=""> <?= esc($card['title']) ?> — <?= esc($card['price'] ?? '') ?></a></li> <?php endforeach ?> </ul> <?php if ($result['disclosure']): ?><small><?= esc($result['disclosure']) ?></small><?php endif ?>
Each card has href (with your referral code), rel, target, title, image, width, height, price, compareAt, discount, isNew and creator. Raw products are in $result['products'], the "view all" link in $result['viewAll'].
Styling
Every rule is :where()-wrapped, so your CSS wins. Set tokens in your stylesheet:
.avdeb { --avdeb-accent: #7c3aed; --avdeb-radius: 4px; --avdeb-card-bg: #fff; --avdeb-font-title: Georgia, serif; }
Tokens: --avdeb-accent, --avdeb-accent-contrast, --avdeb-surface, --avdeb-card-bg, --avdeb-card-pad, --avdeb-border, --avdeb-muted,
--avdeb-badge-bg, --avdeb-badge-text, --avdeb-shadow, --avdeb-shadow-hover, --avdeb-radius, --avdeb-ratio, --avdeb-gap, --avdeb-pad,
--avdeb-font-title, --avdeb-heading-size, --avdeb-title-size, --avdeb-price-size, --avdeb-btn-bg, --avdeb-btn-color, --avdeb-btn-shadow.
The markup uses stable BEM classes (.avdeb, .avdeb--{layout}, .avdeb-card, .avdeb-card__title, .avdeb-card__price, .avdeb-btn…). To use only your own CSS, set 'assets' => false, or load the files yourself with css(avdeb()->assetUrl('avdeb.css')).
How it works
- Embeds call
https://api.avdeb.com/v1/catalog/productsfrom your server. With a secret key, requests sendAuthorization: Bearer avdeb_sk_…and the API returns links that already carry your code; without one,?ref=is added to every link. - Each query is cached in the plugin's cache (
site/cache/…/avdeb/products, or any cache driver you set with'avdeb.products.cache' => [...]). Fresh results are reused forcacheMinutes; a failed request falls back to the last good result (up to a week old) and retries after 15 minutes. At most 30 API calls a minute are made. To refresh products right away, delete that folder or callavdeb()->refresh(). - If you use Kirby's page cache, pages with embeds are cached with their products. Set the page cache to expire within a day so prices stay current.
- All product data is validated before rendering: only
https://avdeb.comlinks andhttps://images get through, and every value is escaped.
Development
php tests/run.php # unit tests for the catalog client, options and renderer (no Kirby needed) tests/dev-site.sh # throw-away Kirby Starterkit in Docker with the plugin and a demo note → http://localhost:8100/panel tests/smoke.sh # fresh site: render every embed against the live API (KIRBY_VERSION=4.8.0 for another version)
Support
Issues and ideas: github.com/Avdebcom/kirby-avdeb/issues. More integrations: avdeb.com/developers.
License
MIT © AVDEB
