EE compatibility updates:

  • Publisher is EE5 compatible, but it does not currently support the Fluid field.

ExpressionEngine.com licenses:

  • 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: bloq_var_ prefix - not able to get working

Status Resolved
Add-on / Version Bloqs 4.4.0
Severity
EE Version 5.4.0

Josh Brodleit

Dec 07, 2020

Added

block_var_

prefix to a bloq, but conditional not outputting. Hoping to actually use this in a child bloq to do determine the “color_background_override” color to properly set font color in child blocks. Please advise and/or let me know if I’m missing something.

{bloq_wrapper_section bloq_var_some_key="some-value"}
	{if bloq_var_some_key == "some-value"}
	    Do something
	{/if}
	<section 
		class="
			{if color_background_override == 'light-grey' OR color_background_override == 'soft-white' OR color_background_override == 'white'}
				t-text-dark
				t-bg-{color_background_override}
			{if:elseif color_background_override == 'dark-grey' OR color_background_override == 'soft-black' OR color_background_override == 'black'}
				t-text-light
				t-bg-{color_background_override}
			{/if}
		"
		data-block-name="bloq_wrapper_section"
	>
		<div class="{section_width} pt-6__5 pb-7__5">
	{close:bloq_wrapper_section}
		</div>
	</section>
	{/close:bloq_wrapper_section}
{/bloq_wrapper_section}

#1

BoldMinded (Brian)

Dec 07, 2020

If you use a bloq_var in a conditional, you will need to quote it, e.g. {if ‘{bloq_var_columns}’ > 2}

#2

Josh Brodleit

Dec 07, 2020

Maybe I’m missing how to configure, but not getting anything to ouput using that syntax either:

{bloq_wrapper_section bloq_var_some_key="some-value"}
 {if '{bloq_var_some_key}' == "some-value"}
     Do something
 {/if}
 <section 
  class="
   {if color_background_override == 'light-grey' OR color_background_override == 'soft-white' OR color_background_override == 'white'}
    t-text-dark
    t-bg-{color_background_override}
   {if:elseif color_background_override == 'dark-grey' OR color_background_override == 'soft-black' OR color_background_override == 'black'}
    t-text-light
    t-bg-{color_background_override}
   {/if}
  "
  data-block-name="bloq_wrapper_section"
 >
  <div class="{section_width} pt-6__5 pb-7__5">
 {close:bloq_wrapper_section}
  </div>
 </section>
 {/close:bloq_wrapper_section}
{/bloq_wrapper_section}
#3

BoldMinded (Brian)

Dec 07, 2020

And you prefixed the atom name?

For shits and giggles, try “block_var_” as the prefix and see if it works. Also try it without the conditional to make sure it’s printing the value.

#4

BoldMinded (Brian)

Dec 07, 2020

This might be the issue too

{bloq_wrapper_section bloq_var_some_key="some-value"}

If bloq_wrapper_section is a bloq, then it won’t work. Setting the bloq_var in this way only works on the parent field, e.g.

<pre><code>
{my_bloqs_field var_some_key=“some-value”}
  {bloq_wrapper_section}
  {/bloq_wrapper_section}
{/my_bloqs_field}
<pre><code>

You either set the variable on the bloqs field, or by prefixing an atom.

 

#5

Josh Brodleit

Dec 07, 2020

Ok, so to clarify, the parent bloq, `bloq_wrapper_section` I wouldn’t be able to access that bloq’s atom value, `color_background_override` in a nested child bloq?

#6

BoldMinded (Brian)

Dec 07, 2020

Yes you can, but color_background_override needs to be named bloq_var_color_background_override

#7

Josh Brodleit

Dec 07, 2020

ok, added that and still not ouputting…unless again, I’m missing something here

Parent Bloq

{bloq_wrapper_section}
 <section
  class="
   {if bloq_var_color_background_override == 'light-grey' OR bloq_var_color_background_override == 'soft-white' OR bloq_var_color_background_override == 'white'}
    t-text-dark
    t-bg-{bloq_var_color_background_override}
   {if:elseif bloq_var_color_background_override == 'dark-grey' OR bloq_var_color_background_override == 'soft-black' OR bloq_var_color_background_override == 'black'}
    t-text-light
    t-bg-{bloq_var_color_background_override}
   {/if}
  "
  data-block-name="
   bloq_wrapper_section
  "
 >
  <div class="{section_width} pt-6__5 pb-7__5">
 {close:bloq_wrapper_section}
  </div>
 </section>
 {/close:bloq_wrapper_section}
{/bloq_wrapper_section}

Child bloq

{bloq_content_table}

 {block_var_color_background_override} - nothing outputs here…

 <div class="{if column_width}col-md-{column_width}{/if}{if margin_bottom != 'default'} {margin_bottom}{/if}" data-block-name="bloq_content_table">
  <div class="table-responsive">
   <table class="table">
          {table}
              {if row_id == 1}<thead>{/if}
              {if row_id == 2}<tbody>{/if}
                  <tr>
                      {columns}
                          {if is_first_row}
                              <th scope="col" data-id="{column_id}">
                                  {value}
                              </th>
                          {if:elseif is_last_row}
                              <td data-id="{column_id}">
                                  {value}
                              </td>
                          {if:else}
                              <td data-id="{column_id}">
                                  {value}
                              </td>
                          {/if}
                      {/columns}
                  </tr>
              {if row_id == 1}</thead>{/if}
              {if row_id == is_last_row}</tbody>{/if}

          {/table}
   </table>
  </div>
 {close:bloq_content_table} 
 </div>
 {/close:bloq_content_table}
{/bloq_content_table}
#8

BoldMinded (Brian)

Dec 07, 2020



{exp:channel:entries entry_id="{segment_2}"}
    <h1>{title}</h1>
    {bloqs}
        {slab}
        <div data-block-name="slab">
            {heading}
            {close:slab}
        </div>
        {/close:slab}
        {/slab}

        {section}
        <div data-block-name="section">
            {heading}
            {close:section}
        </div>
        {/close:section}
        {/section}

        {video}
        <div data-block-name="video">
            {reel}
            {close:video}
        </div>
        {/close:video}
        {/video}

        {basic_content}
        <div data-block-name="content">
            <h2>{content_heading}</h2>
            {content}
            color: {bloq_var_color}
            {close:basic_content}
        </div>
        {/close:basic_content}
        {/basic_content}

        {simple_table}
        <div data-block-name="simple_table">
            {table}
            {/table}
            {close:simple_table}
        </div>
        {/close:simple_table}
        {/simple_table}

        {simple_grid}
        <div data-block-name="simple_grid">
            {grid}
            {/grid}
            {close:simple_grid}
        </div>
        {/close:simple_grid}
        {/simple_grid}

        {featured_entry}
        <div data-block-name="featured_entry">
            {relationship}
            {/relationship}
            {close:featured_entry}
        </div>
        {/close:featured_entry}
        {/featured_entry}
    {/bloqs}
{/exp:channel:entries}
#9

BoldMinded (Brian)

Dec 07, 2020

BTW you can make those conditionals a lot simpler by using a regex (remember bloq_vars need to be quoted):

{if "{bloq_var_color_background_override}" ~ "/^(light-grey|soft-white|white)$/"}
#10

Josh Brodleit

Dec 07, 2020

Ok, sweet! Got it working properly now. Thank you providing the examples.

#11

BoldMinded (Brian)

Dec 07, 2020

Login to reply