1

I can’t seem to figure out how to do this correctly.

I’m using Content Elements as a field and stashing those values as you would typically do in a Stash list. However, when I call that list the sequence of what is being outputted seems to match the sequence in my code and not in the published entry.

Setting the list:

{exp:stash:set_list name="h" parse_tags="yes" parse_depth="2"}
  {h}

   {heading}
             {stash:h_header}{value}{/stash:h_header}
         {/heading}

   {wygwam}                     
       {stash:h_wygwam}{value}{/stash:h_wygwam}
   {/wygwam}

   {assets}                      
       {files}
        {stash:h_assets}{url}{/stash:h_assets}
        {stash:h_assets_alt}{alt_text}{/stash:h_assets_alt}
       {/files}
   {/assets}

  {/h}
{/exp:stash:set_list} 

My template:

{if segment_1 == "about"}
 <div class="row">
  <div class="small-12 columns">
   {exp:stash:get_list name="h"}
    {count}
    {if h_header != ""}{h_header}{/if}
    {h_wygwam}
    {if h_assets != ""}<img src="{h_assets}"alt="{h_assets_alt}">{/if}
   {/exp:stash:get_list}
  </div>
 </div>

{/if} 

Based on the above the {h_header} always gets listed first even though it might not actually be the first entry in the list. Hope this makes sense.

I have a feeling I’m not doing this correctly in Stash and not in Content Elements.

Thanks for the help.

1

Managed to resolve this with the help from Mark Croxton.

Using a list target each content type with the same variable name. Example below:

{exp:stash:set_list name="content-section-1" parse_tags="yes" parse_depth="2"}

  {c}

    {heading}
              {stash:content}{value}{/stash:content}
          {/heading}

    {wygwam}                     
        {stash:content}{value}{/stash:content}
    {/wygwam}

    {assets}                      
        {files}
         {stash:content}<img src="{url}" alt="{alt_text}" />{/stash:content}
        {/files}
    {/assets}

  {/c}

{/exp:stash:set_list}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.