Be sure to checkout our newest add-on Speedy!

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: Passing value to children

Status Resolved
Add-on / Version Bloqs 1.4.2
Severity
EE Version 5.3.2

Johan Hedin

May 13, 2020

Hello, I’ve tried to solve this for a day now but can’t get it to work. I have created a template with a nav bar (mega menu). It has 3 levels of headings. In EE the nav bar is a nested block with the blocks “heading 1”, “heading 2” and “heading 3”. The navbar outputs perfectly with the headings (image). The problem is the links. In each block there is a relationship field that output the related entries URL-title. It works fine for the links on “heading 1” (segment 1), but when I create the link for “heading 2” it needs to pass the URL segment from “heading 1” and then add the URL-title (segment 2) for “heading 2”. And on “heading 3” I need to pass both segment 1 and segment 2.

I’ve tried a lot of different ideas. Tried Stash and probably could work somehow, but haven’t got it to work other than only outputing the first relationship value for the first loop (the value for the first “heading 1” block is given to all “heading 1” blocks). Is there any way I could fetch the values from the parent relationship field to its children?

<ul class="rd-navbar-nav">

{exp:channel:entries channel="x_huvudmenyn" dynamic="no" status="open"}
                
      {huvudmenyn_bloq}  

                            {header_1}
                            <li class="rd-nav-item"><a class="rd-nav-link" href="/sv/{lanka_sida:url_title}">{rubrik}</a>
                                {if "{blocks:children:total_blocks}" > 0}<ul class="rd-menu rd-navbar-megamenu">{/if}
                            {close:header_1}
                            {if "{blocks:children:total_blocks}" > 0}</ul><p>{/if}<br />
                            </p>
</li>
<p>                            {/close:header_1}<br />
                            {/header_1}    <br />
            <br />
                             {header_2}<br />
                             {if "{blocks:parent:shortname}" == "header_1"}</p><li class="rd-megamenu-item"><div><p>{/if}<br />
                                      {if "{blocks:parent:shortname}" == "header_2"}</p><div class="mt-5"><p>{/if}<br />
                                        </p><h5 class="rd-megamenu-title"><a href="/sv/<!-- pass value from header_1-->/{lanka_sida2:url_title}">{rubrik}</h5>
<p>                                        </p><ul class="rd-megamenu-list">
                             {close:header_2}</ul></div>{if "{blocks:parent:shortname}" == "header_1"}</li><p>{/if}<br />
                             {/close:header_2}<br />
                             {/header_2}</p>

<p>                            {header_3} <br />
                            </p><li class="rd-megamenu-list-item"><a class="rd-megamenu-list-link" href="/sv/<!-- pass value from header_1-->/<!-- pass value from header_2-->/{lanka_sida3:url_title}">{rubrik}</a></li><p>  <br />
                            {/header_3}   <br />
                         <br />
       {/huvudmenyn_bloq}<br />
{/exp:channel:entries}<br /></p>
</ul>

Best regards,
Johan

#1

BoldMinded (Brian)

May 13, 2020

You can’t pass field/atom values between blocks, unless nesting is enabled and you’re using block_vars https://docs.boldminded.com/bloqs/docs/nesting#block-variables

#2

Johan Hedin

May 13, 2020

Nested is enabled, and I’m guessing that block-variables probably would work if it accepted relationships. Not tested the relationship field as it says its not supported, but It’s only a text-string..  Is there not any way around this?

#3

BoldMinded (Brian)

May 13, 2020

The relationship field isn’t just a string, it stores data as an array. Unfortunately I don’t have any other recommendations, you’re attempting to do something pretty custom and outside the bounds of Bloqs’ functionality.

#4

Johan Hedin

May 14, 2020

Okay, I understand. I’ll make top-level as a static URL that passes on to its children and have a less deep URL-structure.

Thanks,
Johan

Login to reply

Contact

For add-on support, please use the Support section. General inquries and pre-sale questions can be sent to support@boldminded.com.