assign_block_vars and assign_block_vars_array

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
RobiX
Registered User
Posts: 93
Joined: Thu Oct 05, 2017 9:59 am

assign_block_vars and assign_block_vars_array

Post by RobiX » Fri Dec 08, 2017 9:08 pm

Can someone give me examples for assign_block_vars and especially also assign_block_vars_array.

assign_block_vars
I found this page: https://wiki.phpbb.com/Template.assign_block_vars
"Example #2 Nested blocks": Is there another way instead of using two foreach?

how can this be written in an array construct?

Code: Select all

$template->assign_block_vars('block1 ...
assign_block_vars_array
how can this be written in an array construct?

Code: Select all

  $template->assign_block_vars_array('block1', [
    [ 'block2' => array('a1', 'b1', 'c1', ],
    [ 'block2' => array('a2', 'b2', 'c2', ],
  ]);

User avatar
kasimi
Extension Customisations
Extension Customisations
Posts: 3097
Joined: Sat Sep 10, 2011 7:12 pm
Location: Germany
Contact:

Re: assign_block_vars and assign_block_vars_array

Post by kasimi » Fri Dec 08, 2017 9:30 pm

All that assign_block_vars_array() does is this: https://github.com/phpbb/phpbb/blob/rel ... #L269-L272

RobiX
Registered User
Posts: 93
Joined: Thu Oct 05, 2017 9:59 am

Re: assign_block_vars and assign_block_vars_array

Post by RobiX » Fri Dec 08, 2017 9:35 pm

@kasimi: ok, so the second parameter needs to be an array? mh thank you

User avatar
kasimi
Extension Customisations
Extension Customisations
Posts: 3097
Joined: Sat Sep 10, 2011 7:12 pm
Location: Germany
Contact:

Re: assign_block_vars and assign_block_vars_array

Post by kasimi » Fri Dec 08, 2017 9:42 pm

In your second code block, the 'block2' keys are ignored. Instead, try this:

Code: Select all

$template->assign_block_vars_array('block1.block2', [
    ['a1', 'b1', 'c1'],
    ['a2', 'b2', 'c2'],
]);
The above is the same as this:

Code: Select all

$template->assign_block_vars('block1.block2', ['a1', 'b1', 'c1']);
$template->assign_block_vars('block1.block2', ['a2', 'b2', 'c2']);

Post Reply

Return to “phpBB Custom Coding”

Who is online

Users browsing this forum: No registered users and 3 guests