We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Plugin Problem: Pair Variables

Development and Programming

Milaan's avatar
Milaan
33 posts
16 years ago
Milaan's avatar Milaan

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.

       
silenz's avatar
silenz
1,648 posts
16 years ago
silenz's avatar silenz
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.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.