@bennybernaer
Rather than writing each button in the file, you can store the colours in an array, then iterate over it to generate the corresponding button.
Replace:With:Simply add/remove a colour from the array to change the list of buttons.
And if you need to retrieve these colours from somewhere else (aka another file), you can use phpBB
By defining the COLORS array (in uppercase) in the head:Then, in any file, iterate over
Rather than writing each button in the file, you can store the colours in an array, then iterate over it to generate the corresponding button.
Replace:
Code:
<button id="html_default" title=" default"></button><button id="html_Crimson" title=" Crimson"></button><button id="html_PaleVioletRed" title=" PaleVioletRed"></button><button id="html_MediumOrchid" title=" MediumOrchid"></button><button id="html_BlueViolet" title=" BlueViolet"></button><button id="html_SlateBlue" title=" SlateBlue"></button><button id="html_RoyalBlue" title=" RoyalBlue"></button><button id="html_DodgerBlue" title=" DodgerBlue"></button><button id="html_DarkTurquoise" title=" DarkTurquoise"></button><button id="html_DarkCyan" title="DarkCyan"></button><button id="html_LimeGreen" title="LimeGreen"></button><button id="html_YellowGreen" title="YellowGreen"></button><button id="html_Gold" title=" Gold"></button><button id="html_Orange" title=" Orange"></button><button id="html_Coral" title="Coral"></button><button id="html_Gray" title=" Gray"></button>
Code:
{% set colors = ['default', 'Crimson', 'PaleVioletRed', 'MediumOrchid', 'BlueViolet', 'SlateBlue', 'RoyalBlue', 'DodgerBlue', 'DarkTurquoise', 'DarkCyan', 'LimeGreen', 'YellowGreen', 'Gold', 'Orange', 'Coral', 'Gray'] %} {% for color in colors %}<button id="html_{{ color }}" title="{{ color }}"></button>{% endfor %}
And if you need to retrieve these colours from somewhere else (aka another file), you can use phpBB
DEFINE
instead of the Twig var.By defining the COLORS array (in uppercase) in the head:
Code:
{% DEFINE COLORS = ['default', 'Crimson', 'PaleVioletRed', 'MediumOrchid', 'BlueViolet', 'SlateBlue', 'RoyalBlue', 'DodgerBlue', 'DarkTurquoise', 'DarkCyan', 'LimeGreen', 'YellowGreen', 'Gold', 'Orange', 'Coral', 'Gray'] %}
definition.COLORS
Code:
{% for color in definition.COLORS %}<button id="html_{{ color }}" title="{{ color }}"></button>{% endfor %}
Statistics: Posted by cabot — Mon Apr 14, 2025 11:57 am