Extension, Module

Archived
Forum
(read-only)

Stash

ExpressionEngine 2, ExpressionEngine 3, ExpressionEngine 4, ExpressionEngine 5, ExpressionEngine 6

Back to this add-on's main page
View Other Add-ons From Mark Croxton

     

Backspace content when using get_list?

Feature Request

Maxwell
Maxwell

Would be cool if it was possible to add: backspace=”” parameter to a get_list tag ;)
The current version seems to wig out and backspace the variables inside the list..

Mark Croxton
# 1
Developer
Mark Croxton

I think you may have been using an older version of Stash? Backspace is applied to the whole list for a long while now.

Jon Thomas
# 2
Jon Thomas

I’m having an issue using backspace on a nested get_list. Should this work? I’m trying to output the categories for each entry. It’s still outputting the comma + space after each category.

Setter

{!-- Articles --}
{exp
:stash:set_list name="articles" parse_tags="yes" parse_depth="2"}
    {exp
:channel:entries
        channel
="news"
        
dynamic="no"
        
orderby="sticky|entry_date"
        
sort="desc|desc"
        
sort_type="numeric|numeric"
        
disable="member_data|category_fields"
    
}
        {stash
:id}{entry_id}{/stash:id}
        {stash
:sticky}{sticky}{/stash:sticky}
        {stash
:title}{title}{/stash:title}
        {stash
:summary}{article_summary}{/stash:summary}
        {stash
:date}{entry_date}{/stash:date}
        {stash
:url}{page_url}{/stash:url}
        {stash
:image}{article_featured_image}{/stash:image}

        {exp
:stash:set_list:nested name="this_article_categories" parse_tags="yes" context="{entry_id}"}
            {categories}
                {stash
:category_name}{category_name}{/stash:category_name}
                {stash
:category_url_title}{category_url_title}{/stash:category_url_title}
            {
/categories}
        {
/exp:stash:set_list:nested}
    {
/exp:channel:entries}
{
/exp:stash:set_list} 


Getter

{!-- Get Articles --}
{exp
:stash:get_list name="articles" limit="2" parse_conditionals="yes" prefix="news" process="end"}
<article>
    <
header>
        <
div class="meta">{news:date format="%M %j, %Y"}</div>
        <
h1 class="gamma"><a href="{news:url}">{news:title}</a></h1>
        <
p>
            
{exp:stash:get_list:nested name="this_article_categories" backspace="2" context="{news:id}"}
                
<a href="{category_url_title}">{category_name}</a>, 
            
{/exp:stash:get_list:nested}
        
</p>
    </
header>
    <
div class="article-body">
        
{news:summary}
    
</div>
    <
class="read-more"><a href="{news:url}">Continue reading <class="ss-gizmo ss-right"></i></a></p>
</
article>

<
hr>

{/exp:stash:get_list} 
Mark Croxton
# 3
Developer
Mark Croxton

The backspace parameter applies to the output of the whole list, so will only remove the very last character(s). Note also that a space is a character, so you should use trim=“yes” when setting or getting your list to remove spaces and line breaks, or do it manually:

{exp:stash:get_list:nested name="this_article_categories" backspace="2" context="{news:id}"}<a href="{category_url_title}">{category_name}</a>, {/exp:stash:get_list:nested}