[RFC] Template procedures

Note: We are moving the topics of this forum and it will be deleted at some point

Publish your own request for comments/change or patches for the next version of phpBB. Discuss the contributions and proposals of others. Upcoming releases are 3.2/Rhea and 3.3.
ckwalsh
Registered User
Posts: 54
Joined: Tue Apr 18, 2006 2:25 am

Re: [RFC] Template procedures

Post by ckwalsh » Sun Aug 01, 2010 8:02 pm

Agreed.

I don't think the template language should be expanded much further in a core phpBB install, but I think it is important for each tag implemented to be modular, allowing anyone to easily add logic they require or remove logic they don't.

User avatar
hanakin
Infrastructure Team
Infrastructure Team
Posts: 876
Joined: Sat Dec 25, 2010 9:02 pm
Contact:

Re: Template procedures

Post by hanakin » Sat Dec 25, 2010 9:48 pm

naderman wrote:Slowly I'm starting to wonder why we don't just use PHP instead of our own template language?
+1 to this ie it would be far less confusing and would require less delving into file upon file to figure wtf is happening, and would lead to better themes IE shortform like WP

User avatar
psoTFX
Registered User
Posts: 1984
Joined: Tue Jul 03, 2001 8:50 pm
Contact:

Re: [RFC] Template procedures

Post by psoTFX » Fri Jul 13, 2012 2:34 pm

So - bumping this back after Nil's noted it's existence. I see this is as a kind of "macro" solution (rather than snippet, procedure, function - though a function is what it is). If you were able to send it parameters I could see a use, perhaps. There would also need to be mechanism (imo) to autoload such a macro's template since it could be used anywhere/everywhere and including it manually somewhat defeats the point and could lead to issues (unless it's loaded within the headers).

Oleg
Posts: 1150
Joined: Tue Feb 23, 2010 2:38 am
Contact:

Re: [RFC] Template procedures

Post by Oleg » Fri Jul 13, 2012 7:49 pm

What does this offer that file inclusion does not?

User avatar
psoTFX
Registered User
Posts: 1984
Joined: Tue Jul 03, 2001 8:50 pm
Contact:

Re: [RFC] Template procedures

Post by psoTFX » Fri Jul 13, 2012 10:18 pm

That's a good question and one I've asked myself. I guess in certain circumstances it could lead to fewer includes - the pagination change I made for example. It may offer up more options than a simple include can achieve (unless it's been extended in my absence ofc :D) such as per my example. It seems at the time it had a reasonable fan base - hopefully those peeps can provide more examples (or correct mine!).

User avatar
naderman
Consultant
Posts: 1727
Joined: Sun Jan 11, 2004 2:11 am
Location: Karlsruhe, Germany
Contact:

Re: [RFC] Template procedures

Post by naderman » Sat Jul 14, 2012 3:53 am

I'd say the main prolem is with loops. The way that template variables work an included template file will be using a variable at the top level (or at least some specific level) so you won't be able to reuse the template file inside of a loop as the values will be in loop variables, which don't apply to the included template. So you need some way of specifying which template variables should be top level variables for the included template, essentially ending up with a function/macro mechanism.

Oleg
Posts: 1150
Joined: Tue Feb 23, 2010 2:38 am
Contact:

Re: [RFC] Template procedures

Post by Oleg » Sat Jul 14, 2012 4:03 am

OK, but please consider if passing local variables to included files (either explicitly or implicitly) might be a better approach.

User avatar
naderman
Consultant
Posts: 1727
Joined: Sun Jan 11, 2004 2:11 am
Location: Karlsruhe, Germany
Contact:

Re: [RFC] Template procedures

Post by naderman » Sat Jul 14, 2012 4:24 am

Indeed, when I pointed psoTFX here, I didn't mean to favour any particular implementation.

However I think it would add to clarity if one explicitly defines which variables are parameters and need to be passed into the macro, rather than implicitly expecting variable to be set by whoever includes a template.

Post Reply