Answers.Body: <p>Answer or sort of.</p>
  
  <p>First you cannot pass numbers as index ie. <code>$columnHeaders.1.whatever</code> smarty will print just <code>$columnHeaders</code></p>
  
  <p>Second, same applies for <code>$rows</code>, I guess it holds an array of arrays with perhaps an <code>id</code> for each array with the custom fields, or just an index, if that's the case you need to nest your loops.</p>
  
  <p>Example:</p>
  
  <pre><code>{foreach from=$rows key=index item=row}
       {foreach from=$row key=field item=value}
          &lt;p&gt;{$field}: {$value}&lt;/p&gt;
       {/foreach}
  {/foreach}
  </code></pre>
  
  <p>Hope that gives you a hint and helps.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-20T00:56:58.360Z
Answers.LastActivityDate: 2016-04-20T00:56:58.360Z
Answers.UserDisplayName: Andrei
Body: <p>I'm modifying <code>/templates/CRM/Profile/Page/Listings.tpl</code> to a specific customer need. The profile I need to show using that includes a Multiple Value custom field. </p>
  
  <p>When I tried the Listing with a record (Contact ID) with more than one value in that custom field, is shown multiple times that Contact ID, each one with one value from the Multiple Value custom field.</p>
  
  <p>I turned debug on and the $rows array really shows multiple entries, each one with one value from the Multivalue field.</p>
  
  <p>No matter if I turn <code>is_multi_summary =&gt; "1"</code> on or off, it doesn't change anything. </p>
  
  <p>The code from Listing.tpl I'm working on looks like that:</p>
  
  <pre><code>  {foreach from=$rows item=row name=listings}
    &lt;div id="row-{$smarty.foreach.listings.iteration}" class="{* cycle values="odd-row,even-row" *} ppindiv"&gt;
  
      &lt;p class="crm-{$columnHeaders.2.field_name}"&gt;{$row.2}&lt;/p&gt;
      &lt;div class="crm-{$columnHeaders.1.field_name}"&gt;{$row.1}&lt;/div&gt;
      &lt;p class="crm-{$columnHeaders.5.field_name}"&gt;{$row.5}&lt;/p&gt;
      &lt;p class="crm-{$columnHeaders.7.field_name}"&gt;{$row.7}&lt;/p&gt;
  
    &lt;/div&gt;
    {/foreach}
  </code></pre>
  
  <p>Also, makes no difference if I use the original loop to show the values, like that:</p>
  
  <pre><code>  {foreach from=$row key=index item=value}
      {if $columnHeaders.$index.field_name}
        &lt;p class="crm-{$columnHeaders.$index.field_name}"&gt;{$value}&lt;/p&gt;
      {else}
        {* $value *} 
      {/if}
    {/foreach}
  </code></pre>
  
  <p>Things still got duplicated.</p>
  
  <p>Is it possible to says Smarty to show the Multivalue Field only once, with all the values inside? Like a localized "foreach"?</p>
  
Tags: <profile><joomla><4.7>
Title: Multiple value field makes Listing loop
ThreadText: # Multiple value field makes Listing loop
  
  (Asked by: username_0 on 2016-04-18)
  
  I'm modifying `/templates/CRM/Profile/Page/Listings.tpl` to a specific customer need. The profile I need to show using that includes a Multiple Value custom field.
  
  When I tried the Listing with a record (Contact ID) with more than one value in that custom field, is shown multiple times that Contact ID, each one with one value from the Multiple Value custom field.
  
  I turned debug on and the $rows array really shows multiple entries, each one with one value from the Multivalue field.
  
  No matter if I turn `is_multi_summary => "1"` on or off, it doesn't change anything.
  
  The code from Listing.tpl I'm working on looks like that:
  
  ```
    {foreach from=$rows item=row name=listings}
    <div id="row-{$smarty.foreach.listings.iteration}" class="{* cycle values="odd-row,even-row" *} ppindiv">
  
      <p class="crm-{$columnHeaders.2.field_name}">{$row.2}</p>
      <div class="crm-{$columnHeaders.1.field_name}">{$row.1}</div>
      <p class="crm-{$columnHeaders.5.field_name}">{$row.5}</p>
      <p class="crm-{$columnHeaders.7.field_name}">{$row.7}</p>
  
    </div>
    {/foreach}
  
  ```
  
  Also, makes no difference if I use the original loop to show the values, like that:
  
  ```
    {foreach from=$row key=index item=value}
      {if $columnHeaders.$index.field_name}
        <p class="crm-{$columnHeaders.$index.field_name}">{$value}</p>
      {else}
        {* $value *} 
      {/if}
    {/foreach}
  
  ```
  
  Things still got duplicated.
  
  Is it possible to says Smarty to show the Multivalue Field only once, with all the values inside? Like a localized "foreach"?
  
  **Tags:** profile, joomla, 4.7
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-04-20. Score: 1
  
  Answer or sort of.
  
  First you cannot pass numbers as index ie. `$columnHeaders.1.whatever` smarty will print just `$columnHeaders`
  
  Second, same applies for `$rows`, I guess it holds an array of arrays with perhaps an `id` for each array with the custom fields, or just an index, if that's the case you need to nest your loops.
  
  Example:
  
  ```
  {foreach from=$rows key=index item=row}
       {foreach from=$row key=field item=value}
          <p>{$field}: {$value}</p>
       {/foreach}
  {/foreach}
  
  ```
  
  Hope that gives you a hint and helps.
  
  
  ---
  
  