I’m trying out EE4 these days (finally! 😊 ) … GREAT Update so far. But I kind of stumbled over one thing that confuses me:
Is there a bug with index='{index}'
in EE 4.1.1?
While trying out the new Layout Lists, I just can’t get this to work –> https://expressionengine.com/learn/smarter-breadcrumbs-with-layout-lists … as soon as I add the parameter index='{index}'
to the code, the output of the layout
-tag is empty/NULL … and without the index
-param, it outputs the last item of the layout:set:append
«array» as many times as there are items in it 🤔
This is the code on the article-template:
{layout:set:append name='bc-names'}News{/layout:set:append}
{layout:set:append name='bc-urls'}{path='news'}{/layout:set:append}
{layout:set:append name='bc-titles'}News Overview{/layout:set:append}
{layout:set:append name='bc-positions'}2{/layout:set:append}
{layout:set:append name='bc-names'}Artikel{/layout:set:append}
{layout:set:append name='bc-urls'}{current_url}{/layout:set:append}
{layout:set:append name='bc-titles'}Artikel{/layout:set:append}
{layout:set:append name='bc-positions'}3{/layout:set:append}
… and this in the layout-template:
{if layout:bc-urls}{layout:bc-urls}
{if count == '1'}<ol class="breadcrumb h-contentWrap">{/if}
{if count < total_results} <li class="breadcrumb-elem"><a href="http://{value}%22class=%22breadcrumb-subelem" title="{layout:bc-titles index='{index}'} DEBUG: Element {count}/{total_results} i = {index}; p = {layout:bc-positions}" class="breadcrumb-subelem">{layout:bc-names index='{index}'}</a></li>{/if}
{if count == total_results}<li class="breadcrumb-elem"><span class="breadcrumb-subelem">{layout:bc-names index='{index}'}</span></li>
</ol>{/if}{/layout:bc-urls}{/if}
… my «DEBUG»-portions of the code shows me, that {index}
itself is working properly – just the index
-parameter does somehow not work accordingly.
Bug? Or am I doing something wrong?
Hey Stefan! No, you aren’t doing anything wrong, but it looks like a recent bug fix made these a bit more strict, and the -
in your layout variable names is causing it to not parse them properly. We’ll get that patched up, but in the meantime if you change those to _
, which is the common convention for variable names (alpha-numeric and underscore), everything should work fine.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.