Template Loop

A template loop lets you loop through product, categories, subcategories or pages tied to a page template.

{% pagination template(20) %}
{% define $x = 1 %}
{% loop template('tpl_recipe', 'id', 'desc') %}
  <div class="list_layout {% if $x == 2 %} odd {% define $x = 1 %} {% else %} even {% increment($x) %} {% endif %}">
    <h3><a href="{tpl_recipe.page_url}">{tpl_recipe.page_name}</a></h3>
    <a href="{tpl_recipe.page_url}"><img src="{tpl_recipe.attr_recipe_image}" /></a>
    <a href="{tpl_recipe.page_url}">&raquo; MORE</a>
{% ENDLOOP tpl_recipe %}
<div class="clear:both;"></div>
{% default_pagination("Prev", "Next", 5) %}

Template Loops can be called like any of the following:

  • {% loop product(tpl_recipe) %}
  • {% loop product(tpl_recipe, name, desc) %}
  • {% loop product(tpl_recipe, id, asc) %}

A template loop can loop through any template type based on a page template.

The second and third parameters are not required

Parameter 2: name or id

Parameter 3: asc or desc

Product Template Loop:

  • See variables available for Product Loop

The following output tags are available for Page, Category, Subcategory Template Loop (Please see Product Loop for variables):

{page_name} Page Name
{page_slug} Page Slug
{page_content_7} First 7 words of page content
{page_content_10} First 10 words of page content
{page_content_15} First 15 words of page content
{page_content_25} First 25 words of page content
{page_content_50} First 50 words of page content
{page_content_75} First 75 words of page content
{page_content_100} First 100 words of page content
{page_content_200} First 200 words of page content
{page_content} First 200 words of page content
{page_url} Page URL
attribute slug All product attribute slugs that have been flagged to show externally
Loop Conditionals Click here to learn more about loop conditionals.

This loop requires pagination. Please see the section about pagination on how to implement and what variables are accessible using pagination.

Start your free, no-risk trial today.