Variable Scope Across Blocks

edited May 2017 in Bug Reports
Hi,

I'm finding that params provided to fuel_block() are existing across further calls to fuel_block within the same page load.

e.g.

View:
{fuel_block('some_block', array(foobar='123'))}
{fuel_block('some_block')}

Block:
<?= (isset($foobar) ? $foobar : 'not set') ?>

Output:
123
123

I would expect the output to be "123 not set". Is this intended functionality? If so how to I unset the parameters provided so that further calls to a fuel block does not require my users to provide a full set of params?

Thanks,

D

Comments

  • edited 6:22AM
    That would seem to be expected behaviour. Perhaps the second call should be more like:
    {fuel_block('some_block',array())}
  • edited 6:22AM
    Just seems a little odd to me as it kills any ability for further blocks to have 'default' like behaviour, which in turn makes it more complicated for my users of the CMS.
  • edited 6:22AM
    There is a 'scope' parameter you can pass as an argument to fuel_block's configuration array which can help ensure that those values are unique. The scope value should be a unique string key.
Sign In or Register to comment.