BoldMinded acquires Ansel, support ending for all add-ons. BoldMinded acquires Ansel, support ending for all add-ons. Read More →
Support has been discontinued. Issues remain available as an archive. Support has been discontinued. Issues remain available as an archive.
Adding 'backspace' parameter
#204 opened by Oliver Cannell (IC360)
Description
I'm trying to output all the Categories for an Entry, within a specific Parent, like this: {exp:category_construct:categories entry_id="{entry_id}" group_id="1" parent_id="14"}{construct:cat_name}, {/exp:category_construct:categories}
...and I was really hoping a parameter like backspace="2" could be added to remove the last ", " characters of the very last category output (just like in the EE {categories} tag. Would you be able to add this in add at all? Or is there a workaround? :-)
Replies
- TJ Draper
Replied 8/28/2021 9:36 AM, Edited 9/1/2021 8:42 PM
The
backspace
parameter is a feature of the ExpressionEngine tag parsing engine. It should just work. I don't have an easy test environment to verify that right at this moment, but if you do something like this, it should work and I'm fairly confident I tested this back when I was developing Construct:{exp:category_construct:categories entry_id="{entry_id}"" group_id="1" parent_id="14" backspace="1"}{construct:cat_name},{/exp:category_construct:categories}
If by chance that doesn't work, you can definitely do something like this:
{exp:category_construct:categories entry_id="{entry_id}"" group_id="1" parent_id="14"}{construct:cat_name}{if construct:count != construct:total_results},{/if}{/exp:category_construct:categories}
- Oliver Cannell (IC360)
Replied 9/1/2021 4:16 PM, Edited 9/1/2021 8:42 PM
Using the backspace="2" parameter, seems to perform that function on every loop, rather than just the last one. However, your {if construct:count != construct:total_results},{/if} method has worked. :-)
- TJ Draper
Replied 9/1/2021 8:42 PM
Ahh, actually now that I think about it, the way Construct builds the results and uses the template parser, that makes sense. Glad the other method works!