Publisher does not support the Fluid field type. 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: Can not get new nesting variables

Status Resolved
Add-on / Version Bloqs Blogs 4.0.13
Severity
EE Version EE 5.0.1

Jim Stoll

Dec 14, 2018
Hi, We bought Bloqs few days ago. Based on the documentation, we can get the some Context Variables such as {blogs:id} and {your_field_name:total_blocks type="shortname"} in the template. However, I can not get those new variables such as: {blocks:parent:id} {blocks:parent:shortname} {blocks:children:total_blocks} or {blocks:children:total_rows} {blocks:siblings:total_blocks} or {blocks:siblings:total_rows} Even we have children and parent. Example Code like:
{bloqs_field}
    {section_block}
        <div class="section"}
            <h1>{heading_atom}</h1>
        {close:section_block}
        </div>
        {/close:section_block}

      {blocks:children:total_rows}
    {/section_block}

    {row_block}
      {blocks:parent:id}
        <div class="row"}
            {another_atom}
        {close:row_block}
        </div>
        {/close:row_block}
    {/row_block}
{/bloqs_field}
Could you give us some examples of using those new variables. I’m using EE 5.0.1 and latest version of Publish 2.10.5, and Bloqs with 4.0.13. Thanks, Dan Liu
#1

BoldMinded (Brian)

Comment has been marked private.

#2

Jim Stoll

Hi ,

I used the version that you send us. However, I got an error message below:

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 199752784 bytes) in /var/www/html/system/ee/legacy/libraries/Template.php on line 371.

I have increased memory size. It doesn’t work. Could you help us with this issues?

Thanks, Dan Liu

#3

BoldMinded (Brian)

If you’re getting that error the first place to start is to simplify the template by removing code until it starts working again to figure out what is causing the issue.

#4

BoldMinded (Brian)

It looks like it’s dying when trying to parse snippets on the str_replace line

// Parse assign_to_config variables and Snippets
  if (count(ee()->config->_global_vars) > 0)
  {
   $this->log_item("Config Assignments & Template Partials");

   // Only iterate over the partials present in the template
   $regexes = $this->getGlobalsRegex();

   foreach ($regexes as $regex)
   {
    while (preg_match_all($regex, $this->template, $result))
    {
     foreach ($result[1] as $variable)
     {
      // In case any of these variables have EE comments of their own,
      // removing from the value makes snippets more usable in conditionals
      $value = $this->remove_ee_comments(
       ee()->config->_global_vars[$variable]
      );

      $replace = $this->wrapInContextAnnotations(
       $value,
       'Snippet "'.$variable.'"'
      );

      $this->template = str_replace(LD.$variable.RD, $replace, $this->template);
     }
    }
   }
  }
#5

Jim Stoll

We can get the {blogs_overview:total_blocks} in the template. However, if we use simple code like {blogs_overview} {/blogs_overview} . The system throws the error message.

#6

BoldMinded (Brian)

Can you give more info? I don’t know what {bloqs_overview} is. Describe to me in more detail your template code.

#7

Jim Stoll

Following is code from my template which generated by the blogs field. The blogs_overview is a field with Bloqs type. The overview is a blog which contains 4 text fields {ov_text} {ov_link_text} {ov_link_url} and {ov_side_bar_text}

{blogs_overview}
    {overview}
        {ov_text}
        {ov_link_text}
        {ov_link_url}
        {ov_side_bar_text}
    {/overview}

{/blogs_overview}
#8

BoldMinded (Brian)

And if you remove the {blogs_overview} tag pair the page works again? Did you try removing everything else except for {bloqs_overview} to see if the error still happened?

#9

Jim Stoll

If I remove the {blogs_overview} tag pair, the page show like following:

{overview} {ov_text} {ov_link_text} {ov_link_url} {ov_side_bar_text} {/overview}

I tried to remove everything else except for {bloqs_overview} , I got the the error message.

#10

BoldMinded (Brian)

Jim, try testing with a different Bloqs field or some other setup. I just ran some Selenium tests against over 80 pages with 5-20 blocks per page built with Bloqs using the same build I sent you and they all load fine. Right now I’m unable to replicate the issue, and the error you were getting specifically was something to do with snippet/global variable parsing, which Bloqs doesn’t do. Do you have any global vars that have the same name as a Bloqs field, block, or atom?

#11

Jim Stoll

Finally, I found the issue and fixed it. There is a _partials variable which name is same as Blogs field name. Renaming the _partials variable in the file system didn’t work, until I changed it from CP.

Thank you very much!

Dan

#12

BoldMinded (Brian)

Ah yeah, that probably put it into a loop 😊

Glad you sorted it out!

Login to reply