{@PR-Data} iterates over the products of a category, {@BASKET-PR-Data} over the items in the basket. Sometimes, however, you need a loop for which there is no ready-made tag, for example five rating stars or a list that you put together yourself.
There are three loop families for this.
The only difference between
DC-Loop and DC-ZeroLoop is the way they count. With five iterations, DC-Loop1_position returns the values 1 to 5, and DC-ZeroLoopX_position returns the values 0 to 4. Use DC-ZeroLoop if the position is used as an index in another count that starts at 0.The structure of a custom loop
Each of the three families is used according to the same pattern.The outer bracketing is not an end in itself. It only applies if the count is greater than 0, and thus keeps headings, table frames, and list structures out of the page when there is nothing to show.
A fixed number of iterations
DC-Loop1_set() specifies the count. The argument supports tag-in-tag, so the count can come from another tag.
DC-ZeroLoop
DC-ZeroLoopX works in the same way, but counts from 0.
Unlike with
DC-Loop, the X in DC-ZeroLoop is not a placeholder for a digit from 1 to 3, but a freely selectable name, just like with the free parameters. DC-ZeroLoopSpalten and DC-ZeroLoopZeilen are two independent loops. A maximum of 50 different names is possible per page request; beyond that, the shop does not create any further loops and writes a critical error to the log. The previous documentation lists the tag as DC-ZeroLoop1…3.Iterating over a custom list
DC-DynamicLoop1…3 is passed a list and iterates over its entries.
The following are permitted as the argument of
_set(): a fixed list in the template, another tag as tag-in-tag, or a text variable.
Empty entries are dropped, and spaces at the beginning and end of each entry are trimmed.
a, ,b , c therefore becomes the three entries a, b and c.The 128-character limit of WEBSALE tags does not apply to the list itself, provided it comes in via tag-in-tag. If it is fixed text in the tag, the limit does apply. Therefore, build long fixed lists with
DC-FPX_append() and pass them as tag-in-tag.A different separator
If the entries themselves contain commas, you need a different separator._setseparator() specifies it.
The separator can also be several characters long, for example
||. Upper and lower case do not matter.Entries with markers
If the list comes from a third-party system and the entries there are enclosed by markers instead of separated by a character, use_setSeparatorTags() and _settaggeddata().
_settaggeddata() supports tag-in-tag. This allows you to turn the response of an interface directly into a loop without reformatting it first.- Guide: Displaying products and categories anywhere in the shop
- Guide: Vouchers with multiple currencies
Overview of the tags
All tags are permitted in all templates.
_data and _position only output something within the associated loop.
Related topics
- Guide: Displaying products and categories anywhere in the shop
- Guide: Vouchers with multiple currencies
- Reference: DC- (counters and calculations)
- Basics: Tag basics
