Page 1 of 1

Beginner's guide on Template syntax

Posted: Sat Dec 15, 2018 12:56 pm
by TheDani
This is easy in PHP:

Code: Select all

<?php
$a = "https://www.google.com";
$b = "https://www.phpbb.com";
$c = "https://www.yahoo.com";

echo "<br>Google: $a";
echo "<br>phpBB: $b";
echo "<br>Yahoo: $c"; //like exactly PHP, but Template syntax

But Template syntax, how I could start like that?

Re: Beginner's guide on Template syntax

Posted: Sat Dec 15, 2018 3:15 pm
by eeji
There's a good starting point on the dev wiki here: https://wiki.phpbb.com/Tutorial.Template_syntax
Or if you prefer to use twig syntax have a look here:
viewtopic.php?t=2424606
phpBB syntax is converted to twig internally by the core code so either can be used

Re: Beginner's guide on Template syntax

Posted: Sat Dec 15, 2018 4:05 pm
by TheDani
I know, https://wiki.phpbb.com/Tutorial.Templat ... _Variables.
But how?

Code: Select all

<!-- DEFINE $CLASS1 = 'https://www.google.com' -->
<!-- DEFINE $CLASS2 = 'https://www.phpbb.com' -->
<!-- DEFINE $CLASS3 = 'https://www.yahoo.com' -->

<br>Google: {{ $CLASS1 }};
<br>phpBB: {{ $CLASS2 }};
<br>Yahoo: {{ $CLASS3 }};
?
This is not Template syntax, but I don't know about it.

Re: Beginner's guide on Template syntax

Posted: Mon Dec 17, 2018 11:00 am
by TheDani
I've got it.

Code: Select all

<!-- DEFINE $TEXT1 = 'https://www.google.com' -->
<!-- DEFINE $TEXT2 = 'https://www.phpbb.com' -->
<!-- DEFINE $TEXT3 = 'https://www.yahoo.com' -->

<br>Google: {$TEXT3}
<br>phpBB: {$TEXT2}
<br>Yahoo: {$TEXT3}

Re: Beginner's guide on Template syntax

Posted: Fri Jan 18, 2019 8:11 pm
by TheDani
Another thing. How can I do multiple times? Example

Code: Select all

<!-- DEFINE $NUMBER = 0 -->
<!-- IF not forumrow.S_IS_CAT -->
        <div class="{$NUMBER}+1">Hello world</div> <!-- it should be 1, then 2, then 3 etc, but no. 0, 0 and 0 -->
<!-- ENDIF -->
I also thinking <!-- $NUMBER = 0 -->
and {$NUMBER}+1 or {$NUMBER} + 1 or {$NUMBER+1} or {$NUMBER + 1}
But no go.

PHP is easy:

Code: Select all

$number = 0;
<!-- IF not forumrow.S_IS_CAT -->
        <div class="<?php echo $number+1 ?>">Hello world</div>
<!-- ENDIF -->

Help me.

Re: Beginner's guide on Template syntax

Posted: Tue Jan 22, 2019 7:47 pm
by Hanakin
https://twig.symfony.com/doc/2.x/tags/set.html

then {% x += 1%} should work IIRC