Twig Extensions
Prodyflow provides several custom Twig functions and filters to simplify template rendering and access webshop data.
Key Functions
-
include_html(path)
Includes an external HTML file from the template files. Useful for reusable content blocks. -
linklists(name)
Returns a structured array of menu items and subitems for navigation rendering. Theurlof every item already has the sale channel's prefix. -
shop_url(path)
Returns a path inside the current sale channel:/{language}/{slug}/{path}, or/{slug}/{path}on a channel with one language (no language segment), and the plain path when the channel has no slug.{{ shop_url('profile') }}is the customer's profile page,{{ shop_url() }}the channel's home. -
order_manage()
Renders the order management dialog (return, exchange, change of address or size, cancel, message). Put it once into a page that lists the customer's orders (pages/profile/orders.twig). Its parts can be restyled from the template, see Order management dialog. -
remote_font(font)
A Google Fonts stylesheet served from the shop's own domain, as an inline<style>, with the font files proxied and preloaded. The argument is a Google Fonts URL or a short form, e.g.{{ remote_font('Jost:wght@300..700') }}. When Google is not reachable the page gets a plain stylesheet link of the same proxy. Put it in the<head>oftheme.twig.
Key Filters
asset_url(value)– Generates the full URL for assets in the template's assets folder.t(value)– Returns the translated value from the section settings based on the current locale. Falls back to the default language or the first available value.trans(key, replace, locale)– Returns the translated value from the global translations based on the current locale. Falls back to the default language or the first available value. A key that is not in the engine's own language files is looked up among the template's own texts (theme.<key>), see Theme texts.json(value)– Encodes an array or object as a JSON string (for adata-attribute or a script).
Media Filters
image_url(value, {size})– Returns the correct URL for an image. Supports various sizes and different image sources.sizeis a number (the width in pixels) orsmall,medium,large; for a product image they are 262, 582 and 1440 pixels wide, and 720 withoutsize. For an image given as an object withsizesthe first size that is at least that wide is used.image_srcset(value)– Generates asrcsetattribute for responsive images.video_srcset(value)– Generates an array of video sources with different qualities for adaptive streaming.video_poster(value)– Returns the path for a video poster image.
URL Filters
localized_url(value)– Returns the localized URL for a given path.sale_channel_url(value)– Returns the full webshop URL for a specific sales channel, given by its slug.shop_link(link)– For a link typed into a block setting (a slide, a menu item, a card): an internal path without the channel prefix (/loungewear) gets it (/hu/huf/loungewear). These stay as they are: an absolute URL, an anchor,mailto:andtel:, a link that has the prefix already (or points to another sale channel), and the routes that are not under the channel (/invoice,/label,/track,/images,/icons,/css,/js,/fonts,/storage,/api,/robots.txt,/sitemap*.xml). Use it for every link a merchant can type in the block editor:<a href="{{ slide.link | shop_link }}">.
Money Formatting
money(value)– Formats a numeric value as a currency string. A price object ({amount, currency}) is formatted with its currency, following the template's money format (config.json→money); a plain number is grouped with spaces and has no decimals.
Theme texts
The texts of the template's own pages (labels, buttons, messages) are written in the Twig file, with the default text and its language:
<button>{{ 'cart.buttons.checkout'|trans|default('Tovább a pénztárhoz', 'hu') }}</button>
- The key is
file.keylike the engine's own texts (cart.buttons.checkout= thebuttons.checkoutkey of thecartlanguage file). A key the engine already has is translated from there, and its text is used. - A key the engine does not have is a theme text: the engine finds it in the template (
'key'|trans|default('text'[, 'locale'])) and registers it in Prodyflow, in the translation filetheme, with the default text as the text of its language. The default text is never overwritten. Translators then see it next to the other files in the translator of the block editor, and the shop receives the translations like any other file. In the Twig thetransfilter finds it astheme.<key>. - The language of the default text is the second argument of
default()when it is a language code, elsedefault_localeof theconfig.json, elsehu. - Write the second argument whenever the default text is not in the template's
default_locale.
After the template's texts are imported in a new language, import the default-language texts too, or the translator will create an empty row for them and the page shows the other language's text.
These Twig extensions allow templates to remain clean, while providing powerful tools for dynamic content, localization, media handling, and formatting directly within the Twig layer.