Beginner's guide on Template syntax

For support and discussion related to templates, themes, and imagesets in phpBB 3.2.
Post Reply
TheDani
Registered User
Posts: 394
Joined: Tue Apr 10, 2012 12:48 pm

Beginner's guide on Template syntax

Post 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?
User avatar
eeji
Registered User
Posts: 1461
Joined: Fri Dec 12, 2008 9:08 pm
Location: Manchester, UK
Contact:

Re: Beginner's guide on Template syntax

Post 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
My phpBB styles: phpbbstyles.iansvivarium.com
My "board": iansvivarium.com
(yes, it's running phpBB!)
TheDani
Registered User
Posts: 394
Joined: Tue Apr 10, 2012 12:48 pm

Re: Beginner's guide on Template syntax

Post 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.
TheDani
Registered User
Posts: 394
Joined: Tue Apr 10, 2012 12:48 pm

Re: Beginner's guide on Template syntax

Post 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}
TheDani
Registered User
Posts: 394
Joined: Tue Apr 10, 2012 12:48 pm

Re: Beginner's guide on Template syntax

Post 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.
User avatar
Hanakin
Front-End Dev Team Lead
Front-End Dev Team Lead
Posts: 1065
Joined: Wed Dec 30, 2009 8:14 am
Name: Michael Miday
Contact:

Re: Beginner's guide on Template syntax

Post by Hanakin »

https://twig.symfony.com/doc/2.x/tags/set.html

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

Return to “[3.2.x] Styles Support & Discussion”