Quantcast
Channel: phpBB.com
Viewing all articles
Browse latest Browse all 2375

phpBB Custom Coding • Re: [SOLVED] Does anyone understand Twig macros?

$
0
0
You don't have to use a macro, an include will do the job whatever the template using DEFINE.

overall_header/head (I've removed the is not empty check which doesn't add anything in the context):

Code:

{% set lang_file = 'language/' ~ S_USER_LANG ~ '/style_strings.twig' %}{% if source(lang_file, ignore_missing=true) %}{% include lang_file %}{% else %}{% include 'language/en-gb/style_strings.twig' %}{% endif %}
style_strings.twig:

Code:

{% DEFINE LANG_KEY_1 = "String 1" %}{% DEFINE LANG_KEY_2 = "String 2" %}
Any template file:

Code:

{{ definition.LANG_KEY_1 }}{{ definition.LANG_KEY_2 }}
It goes without saying that you can use twig or html for the language keys.

Statistics: Posted by cabot — Sat Apr 12, 2025 10:37 am



Viewing all articles
Browse latest Browse all 2375

Trending Articles