The attached add-on files may be out of date. Please visit Devot-ee for the latest versions.
Hi,
I have rewritten ben’s For Loop plugin. The result is Loop Plus plugin.
PARAMETERS
1) start - Optional. Represents the starting value of the index. The default value is 1.
2) end - Optional. Represents the end value or limit of the index. The default value is 3.
3) increment - Optional. Represents the incremental value of the index on each iteration of the loop. The default value is 1.
VARIABLES
1) {index} - used to get the value of the index that is incremented in each iteration of the loop.
2) {loop_count} - used to get the number of times that the loop has been iterated over.
VARIABLE PAIR
1) {loop_area}{/loop_area} - Optional. Used to mark area which should be iterated.
USAGE
Use as follows:
{exp:loop_plus start="5" end="10" increment="1"}
This loop has been executed {loop_count} times and is now on iteration number {index}.
{/exp:loop_plus}
Or use {loop_area}{/loop_area} variable pair to mark an area which should be looped:
{exp:loop_plus start="5" end="10" increment="1"}
Some code
{loop_area}
This loop has been executed {loop_count} times and is now on iteration number {index}.
{/loop_area}
Some code
{/exp:loop_plus}
WHY NEW LOOPING PLUGIN?
I was dissatisfied with the original plugin because using it was not possible to output efficiently the code as this:
{exp:weblog:entries weblog="my_weblog" url_title="{segment_3}"}
{if custom_field_1 != ""}{custom_field_1}{/if}
{if custom_field_2 != ""}{custom_field_2}{/if}
{if custom_field_3 != ""}{custom_field_3}{/if}
...
{if custom_field_49 != ""}{custom_field_49}{/if}
{if custom_field_50 != ""}{custom_field_50}{/if}
{/exp:weblog:entries}
Because of the parse order the code as this did not work:
{exp:weblog:entries weblog="my_weblog" url_title="{segment_3}"}
{exp:for_loop start="1" end="50" increment="1"}
{if custom_field_{index} != ""}{custom_field_{index}}{/if}
{/exp:for_loop}
{/exp:weblog:entries}
This code worked:
{exp:for_loop start="1" end="50" increment="1" parse="inward"}
{exp:weblog:entries weblog="my_weblog" url_title="{segment_3}"}
{if custom_field_{index} != ""}{custom_field_{index}}{/if}
{/exp:weblog:entries}
{/exp:for_loop}
But it was inefficient since exp:weblog:entries were initiated on each iteration.
Loop Plus plugin solves this problem by introducing optional {loop_area}{/loop_area} variable pair. Using it it is possible to write the code as this:
{exp:loop_plus start="1" end="50" increment="1" parse="inward"}
{exp:weblog:entries weblog="my_weblog" url_title="{segment_3}"}
{loop_area}
{if custom_field_{index} != ""}{custom_field_{index}}{/if}
{/loop_area}
{/exp:weblog:entries}
{/exp:loop_plus}
This way there is no performance loss since exp:weblog:entries is initiated only once.
You can even use several {loop_area}{/loop_area} variable pairs inside one {exp:loop_plus} tag.
Conditionals are supported.
Hi Laisvunas
would it be possible to loop the following EE code
{exp:weblog:entries weblog="web_projects" category="11"}
{exp:weblog:categories weblog="web_projects" style="linear "show="11"}
{category_name}
{title}
{/exp:weblog:categories}
{/exp:weblog:entries}
I want achieve a dynamic list that displays all entries from all categories from a specific weblog (maybe there is another way out there). There is the {wiki:categories} tag that does exactly what I need, but that is only working for wiki templates? http://expressionengine.com/docs/modules/wiki/wiki_templates_special_categories.html#wiki_tag_categories Thanks
Hi Interfacer,
It seems that you can achieve what you need using either Weblog Categories Tag or Weblog Category Archive Tag.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.