OnArcade 2.3: Template editor
From onArcade Wiki
onArcade 2.3 has much more advanced template editor built into administration panel. onArcade 2.3 template editor has syntax highlighting, bigger editing field and simpler code. Saving and loading is done using AJAX. Unlike in previous versions, there is no global list anymore, it is generated automatically.
Contents |
Syntax highlighting
Syntax highlighting makes it easier to read and edit template code.
Template code
Most of the time you use regular HTML code, but there are some special tags.
Variables
Variables can be used on templates like this:
{$variable}
{$array[0]}
It is also possible to use functions that return something:
{(nohtml('<test>'))}
Because onArcade 2.3 generates global list automatically then it is possible to use all variables available in PHP code also on the template.
Conditions
onArcade supports conditions, contents between condition tags is only displayed if value of conditions is true. For example in the following example "HELLO WORLD!!!" is only shown if the value of variable $a is 1.
{if $a == 1}
HELLO WORLD!!!
{/if}
In the following example "HELLO WORLD!!!" is shown if the value of variable $a is 1, if the value of variable $a is 2 then "BYE!" is shown and if neither of these conditions is true then "???" is shown. It is possible to add more than one {elseif $a == $b} tag between {if $a == 1} and {/if} tags. There can only be one {else} tag and it has to be the last one before {/if} tag.
{if $a == 1}
HELLO WORLD!!!
{elseif $a == 2}
BYE!
{else}
???
{/if}
Loops
Loops can be used to display values from an array. onArcade 2.3 supports foreach and for loops.
{foreach $users AS $user}
{$user}<br />
{/foreach}
{for $i = 0; $i < 10; $i++}
{$users[$i]}<br />
{/for}
Load other template
It is possible to load other templates inside templates. Template file has to be loaded in PHP code first, so it is usually wise to only load templates that are in the same file with the loading template, because that way they are always available. The following code loads template called "menu".
{template menu}
Include PHP file
onArcade 2.3 allows including PHP files inside templates.
{include test.php}
