Skip to main content

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. The url of 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> of theme.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 a data- attribute or a script).

Media Filters​

  • image_url(value, {size}) – Returns the correct URL for an image. Supports various sizes and different image sources. size is a number (the width in pixels) or small, medium, large; for a product image they are 262, 582 and 1440 pixels wide, and 720 without size. For an image given as an object with sizes the first size that is at least that wide is used.
  • image_srcset(value) – Generates a srcset attribute 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: and tel:, 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.key like the engine's own texts (cart.buttons.checkout = the buttons.checkout key of the cart language 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 file theme, 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 the trans filter finds it as theme.<key>.
  • The language of the default text is the second argument of default() when it is a language code, else default_locale of the config.json, else hu.
  • 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.