TinyButStrong - the PHP Template Engine
Categories > TinyButStrong general >

Dynamic Block Name

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs

By: flodi
Date: 2015-07-30
Time: 15:17

Dynamic Block Name

It is possible to have dynamic block names?

Something like [[var.name].value] to show 'value' when merged and call the block with the content of the variable 'name'.

I'm reusing a template dynamically and I need to call the blocks in different ways depending on the caller.

Thank you.
By: Skrol29
Date: 2015-07-31
Time: 11:25

Re: Dynamic Block Name

Hi Flodi,

Yes it is possible but you have to ensure that the field for the name is merged before the block.

For example :  [[onload.name].value]

Or :
[[block_name].value]
with the PHP side :
$TBS->MergeField('block_name', 'my_block');
...
$TBS->MergeBlock('my_block', $data);
By: flodi
Date: 2015-07-31
Time: 11:33

Re: Dynamic Block Name

You're my saviour! Thank you!