We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Index in Layout Lists not working

Development and Programming

Stefan Rechsteiner's avatar
Stefan Rechsteiner
442 posts
7 years ago
Stefan Rechsteiner's avatar Stefan Rechsteiner

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?

       
Derek Jones's avatar
Derek Jones
7,561 posts
7 years ago
Derek Jones's avatar Derek Jones

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.

       
Stefan Rechsteiner's avatar
Stefan Rechsteiner
442 posts
7 years ago
Stefan Rechsteiner's avatar Stefan Rechsteiner

Hey Derek! ? … hehe, ok, actually haven’t tried variable-names without the hyphen since I’m always using this syntax! 😊 well thank you very much, I’ll use _ instead of - until the patch comes out 😊

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.