Your EE module, plugin, and extension marketplace!

Our Newsletter


Click to enlarge

Loop Plugin

RRP:
Price:
$0.00
Vendor:
PutYourLightsOn
Brand:
Weight:
Rating:
()
Availability:
Shipping:
Gift Wrapping:

Quantity:


Product Description

 

This is an Expression Engine plugin that allows you to perform loops within any template without having to enable php.

* Current Version: 1.1 (released 28 April 2008)
* Works with ExpressionEngine 1.6 and higher.


Concept

The only way of putting repetitive numerical values into your templates is either by hard-coding them in or by enabling and using php to do it. I always try to avoid enabling php in templates for security purposes, and hard-coding in for example a drop-down select box with 100 values is never fun.

This plugin solves the problem by allowing you to perform loops in your templates.


How It Works

The loop plugin works just like a simplified for loop does. It takes as parameters an initial value, an increment value, and a limit.

Here is an example of using the loop plugin to create a drop-down select box that allows the user to select the year in which they were born:

<select name="year"> 
  <option value="">Select year</option>
{exp:for_loop start="1940" end="2008" increment="1"}  
  <option value="{index}">{index}</option>
{/exp:for_loop}
</select> 
	

Produces: 

The start parameter is optional and represents the starting value of the index. The default value is 1.

The end parameter is optional and represents the end value or limit of the index. The default value is 3.

The increment parameter is optional and represents the incremental value of the index on each iteration of the loop. The default value is 1.

The index variable is used to get the value of the index that is incremented in each iteration of the loop.

The loop_count variable can be used to get the number of times that the loop has been iterated over.

Another example that simply produces an arithmetic series:

{exp:for_loop start="0" end="99" increment="3"}  
  {if {loop_count} != 1},{/if} {index}
{/exp:for_loop}
	

Produces: 
0 , 3 , 6 , 9 , 12 , 15 , 18 , 21 , 24 , 27 , 30 , 33 , 36 , 39 , 42 , 45 , 48 , 51 , 54 , 57 , 60 , 63 , 66 , 69 , 72 , 75 , 78 , 81 , 84 , 87 , 90 , 93 , 96 , 99

This example shows how decrementing is possible:

{exp:for_loop start="2008" end="2000" increment="-1"}  
  {if {loop_count} != 1},{/if} {index}
{/exp:for_loop}
	

Produces: 
2008 , 2007 , 2006 , 2005 , 2004 , 2003 , 2002 , 2001 , 2000


Installation

  1. Download and unzip loop.zip
  2. Upload pi.for_loop.php to the system/plugins folder.

 


Find Similar Products by Category

Write your own product review

Product Reviews

This product hasn't received any reviews yet. Be the first to review this product!

Add to Wish List

Click the button below to add the Loop Plugin to your wish list.

You Recently Viewed...




Clicky Web Analytics