Where's the documentation?

All style (template, theme and imageset) related questions for the new release; advice, feedback here please.
Post Reply
palin88
Registered User
Posts: 3
Joined: Wed Jan 21, 2009 9:38 pm

Where's the documentation?

Post by palin88 »

Is there any place that has a definitive list of all the features of the template system?

I've been browsing phpbb.com, area51, the dev wiki, the knowledgebase and even the project svn and so far I'm at a loss. The sticky at the top of this forum has an explanations of "new" features to the template system, but that's useless to me since I don't know even the basics. Aside from reverse engineering existing template files is there any way to learn all the different keywords and macros available?

palin88
Registered User
Posts: 3
Joined: Wed Jan 21, 2009 9:38 pm

Re: Where's the documentation?

Post by palin88 »

Ok, apparently there isn't a current listing of all the variables available in the template system. Or at least that's what I'm lead to believe after reading several topics on phpbbhacks and startrekacademy. I can narrow down my question though: is it possible to retrieve the current user's ID while in the template? I want to use it to generate a form query.

Would the following work?

Code: Select all

$template->assign_var( 'USER_ID' , $user->data['user_id'] );

palin88
Registered User
Posts: 3
Joined: Wed Jan 21, 2009 9:38 pm

Re: Where's the documentation?

Post by palin88 »

Hmm, well I've managed to stumble through this without documentation, mostly by copying examples out of other people's code. I think I understand how the modules/templates are loaded now.

Regardless, the tutorials need a real overhaul at the moment.

User avatar
Acyd Burn
Posts: 1838
Joined: Tue Oct 08, 2002 5:18 pm
Location: Behind You
Contact:

Re: Where's the documentation?

Post by Acyd Burn »

palin88 wrote:Is there any place that has a definitive list of all the features of the template system?
Yes, have a look at the coding guidelines HTML document within the docs/ folder of the phpBB3 package you can download at phpbb.com. It is directly provided with phpBB itself.

An online version is here:
http://area51.phpbb.com/docs/coding-gui ... templating

The template engines possible calls are documented here (if you do not want to simply open includes/template.php and have a look for yourself):
http://area51.phpbb.com/docs/code/phpBB3/template.html

Image

User avatar
Acyd Burn
Posts: 1838
Joined: Tue Oct 08, 2002 5:18 pm
Location: Behind You
Contact:

Re: Where's the documentation?

Post by Acyd Burn »

Exact examples are within the wikis tutorial section...

http://wiki.phpbb.com/Template_Syntax

Image

Alden
Registered User
Posts: 2
Joined: Sat Mar 21, 2009 12:46 am

Re: Where's the documentation?

Post by Alden »

I came looking for the same answers, palin88.

It sounds like you've figured out what you needed to know.

For others with the same question, let me answer part of what you asked, specifically about a list of all the variables available for reference in the HTML template text. The answer is probably obvious and hard to forget once known, but you can poke around a bit before coming across it.

Taking the viewtopic template as an example, the key files are:
  • phpbb3/viewtopic.php, the template controller, located at the forum root
  • phpbb3/styles/prosilver/template/viewtopic_body.html, the template text
All the variables available for substitution via expressions like {S_IS_LOCKED} are listed and assigned in viewtopic.php in the forum root, starting with the line:

Code: Select all

$template->assign_vars(array(
...and several similar blocks throughout the script.

Examining viewtopic.php shows the relatively small handful of API calls the template controller uses to gather and format the data it provides in the form of template variables. Of course you'd only need to know how to do that if you were going to add a whole new page to the interface, not for merely writing a new style.

The connection from viewtopic.php to viewtopic_body.html is established a few lines from the bottom of viewtopic.php, with the lines:

Code: Select all

$template->set_filenames(array(
	'body' => ($view == 'print') ? 'viewtopic_print.html' : 'viewtopic_body.html')
The row-specific variables available in the form {postrow.VARIABLE} are listed and assigned in a statement starting

Code: Select all

$rowset[$row['post_id']] = array(
The coding-guidelines.html document suggested above does a good job of explaining the looping constructs, so I won't comment on them.

I'm new to phpBB, too. Modifying one of the standard templates is indeed the fastest route to a new skin but it isn't the fastest or best route to a real understanding. I hope I could find the time later this year to put together a tutorial that builds a stand-alone, truly bare-bones "stick-figure" skin starting from a blank page. It would teach all the elements without the distraction and confusion that comes from trying to merge, overlap, and optimize them for good interface design. Good design can come after the elements are understood individually. Sometimes looking at prosilver and subsilver2, it's hard to tell what is an arbitrary decision that one could make differently and what is structurally essential. I think that's what a "stick-figure" tutorial could resolve. And I think maybe I know just the guy to do it. :lol:

Alden
Registered User
Posts: 2
Joined: Sat Mar 21, 2009 12:46 am

Re: Where's the documentation?

Post by Alden »

And a follow-up to my previous post (not yet moderator-approved, but I'm assuming...):

If you want to know all the variable names available to you in a particular template, go to

Admin->General->ServerConfiguration->Security and enable PHP in templates. You'll want to do this experiment on a local copy of your board or at least, if you can't set that up, on a style on your main board that no regular users can access.

Then insert the following code right after <!-- INCLUDE overall_header.html --> or the equivalent for your base template.

Code: Select all

<div>
  <pre>
    <!-- PHP -->
      global $template;
      print_r($template->_tpldata);
    <!-- ENDPHP -->
  </pre>
</div>
This will show you every single variable name and its value (useful for seeing what kind of data it is, what the paths are relative to, etc.). This method is definitive, unlike analyzing the logic in the template controller.

Don't forget to go to Admin->Styles and Refresh the templates for the style you're doing this with. Just cleaning your cache on the Admin front page won't necessarily show your test template.

Post Reply