assign_vars() or assign_block_vars()

Discuss the development of future releases of phpBB (phpBB 3.x minor releases) and MODing/Coding related questions.
Post Reply
User avatar
TheNick
New member
New member
Posts: 10
Joined: 06 Jul 2009, 18:51
Real name: Niklas
Location: Toenisvorst, Germany
Contact:

assign_vars() or assign_block_vars()

Post by TheNick »

Hey,
I'd like to create my first own MOD, but I need some assistance in this basic question:
What's the difference between assign_vars() and assign_block_vars(). This two methods are required (ok, not really, they're but useful) in phpBB-based pages.
I just noticed, that assign_block_vars is used for arrays, while assign_vars is used for variables.

Is that the only difference?

Greets,
Niklas
PM me for MOD-translations into German
My website - CTO Elektrotipps.de
User avatar
onehundredandtwo
Past Contributor
Past Contributor
Posts: 48
Joined: 23 Jul 2009, 19:47

Re: assign_vars() or assign_block_vars()

Post by onehundredandtwo »

Pretty much, but they both have a different syntax.

For assign_vars() -

Code: Select all

$template->assign_vars(array(
   'VARIABLE'         => $variable,
));

and the variable can be accessed in the style by using {VARIABLE}.

For assigni_block_vars() -

Code: Select all

$template->assign_block_vars('row',array(
   'ARRAY_VAR'         => $variable,
));

and the array can be accessed by using <!-- BEGIN row -->{row.ARRAY_VAR}<!-- END row -->

onehundredandtwo.
User avatar
TheNick
New member
New member
Posts: 10
Joined: 06 Jul 2009, 18:51
Real name: Niklas
Location: Toenisvorst, Germany
Contact:

Re: assign_vars() or assign_block_vars()

Post by TheNick »

Ah, I see. Thank you!

Ciao,
Niklas
PM me for MOD-translations into German
My website - CTO Elektrotipps.de
User avatar
Obsidian
Supporter
Supporter
Posts: 736
Joined: 13 May 2008, 15:20
Real name: Damian
Contact:

Re: assign_vars() or assign_block_vars()

Post by Obsidian »

Also, there's the fact that assign_block_vars() is used to build a template loop. Any kind of list that you see generated in phpBB is usually built with the help of assign_block_vars().
Post Reply