Publisher is EE6 compatible, but it does not support the Fluid field. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: Multiple Bloq Variable Scoping Not Sending All Variables to Parent

Status Resolved
Add-on / Version Bloqs 4.12.4
Severity
EE Version 6.3.2

COLS Secretary

Apr 24, 2022

On a brand new EE install and where Bloqs is currently only active add-on installed and on the page, I run into the following issue when trying to use Bloq Variable Scoping:

I am creating bloqs that can style a parent bloq - these styles can be applied to different parent bloqs - but when they are parsed, only one seems to get sent up to the parent in this case (the padding bloq). If I remove the padding bloq from parsing, the background_color one parses, and so on.

But in any case, only 1 gets sent up to the section bloq. I’ve tried different names for the variables {choice}.

My best guess is they are being overwritten instead of appended/prepended.


{exp:channel:entries require_entry="yes"}
	{page_builder}
		{padding}
			{bloqs:set name="padding" value="{choice}” scope=”{bloqs:parent:id}”}
		{/padding}
		
		{background_color}
			{bloqs:set name="background_color" value="{choice}” scope=”{bloqs:parent:id}”}
		{/background_color}
		
		{border_color}
			{bloqs:set name="border_color" value="{choice}” scope=”{bloqs:parent:id}”}
		{/border_color}
	
		{section}
			{bloqs:get:scoped:padding}
			{bloqs:get:scoped:background_color}
			{bloqs:get:scoped:border_color}
			{bloqs:children}
		{/section}
	{/page_builder}
{/exp:channel:entries}
            
#1

COLS Secretary

Apr 24, 2022

I tried to do my best at finding the issue in the Bloqs codebase.

In Controller/TagController.php at line 505 I changed:

$this->blockVarsScoped = array_replace($this->blockVarsScoped, $parser->getScopedVariables());

to

$this->blockVarsScoped = array_replace_recursive($this->blockVarsScoped, $parser->getScopedVariables());

The function change from “array_replace” to “array_replace_recursive” seems to be doing the trick so far. I will keep testing for my use case, but without knowing the full implications of this kind of change I think it should still be investigated further as there might be another solution or something else causing the issue.

#2

BoldMinded (Brian)

Apr 25, 2022

Thank you for providing a clean code sample and screenshot. I’ll replicate this locally and see if I get the same result.

#3

BoldMinded (Brian)

Apr 25, 2022

Just checked this locally. Your suggested change is good and it works for me too. I’ll include this in the next release. Thanks for pointing this out and suggesting the change!

Login to reply