Hello,
im developing my own plugin where i have an array with names and i want to display these names in a table, each name in a new row.
Array Example:
array('Ben', 'John', 'Joe');
If im right, the template code for what i want should look something like this:
<table>
{exp:contacts:names type="friends"}
<tr>
<td>{contact_name}</td>
</tr>
{/exp:contacts:names}
</table>
My first Questions is…. Do i need an addition Pair Variable between the {exp:contacts:name} tags?
Something like this…
{exp:contacts:names type="friends"}
{contact}
{contact_name}
{/contact}
{/exp:contacts:names}
My second Question is… Does anyone have a template how exactly i need to program this?
I know how it works with single variables but i have no clue about pair variables.
Hello, My first Questions is…. Do i need an addition Pair Variable between the {exp:contacts:name} tags?
If the method names() is exclusively used for looping through the array of names there is no need for a variable pair. You could compare that to a weblog:entries-tag which loops over all entries an pulls the title-field one at a time.
If you would want to output another array inside this loop, e.g. a list of books each of the persons have written, you’d use a variable pair (loop inside loop). Like a list of categories every entry is assigned to.
For an example you could just look into mod.weblog.php how {categories}{/categories} is dealt with.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.