Array as List

chrisdavies71 21 Jun, 2013
Hi,

I have an array of file names which I can include in an email with {filenames} and this works as expected.

Is it possible to break this into a <li>**filename**</li> for each file name rather than it being a comma separated list?

CHRIS
GreyHead 22 Jun, 2013
Hi Chris,

There are two ways to do this:

If you are using a Handle Arrays action to convert the array to a list the quick fix is to set the separator to <br /> which will give each filename a separate line.

If you need a full unordered list then you can add a custom code action to format the list, replacing 'file_list' with the name of your file array:
<?php
$temp = array();
foreach ( $form->data['file_list'] as $v ) {
  $temp[] = '<li>'.$v.'</li>';
}
$form->data['formatted_list'] = '<ul>'.implode('', $temp).'</ul>';
?>
Then put {formatted_list} in the email template.

Bob
This topic is locked and no more replies can be posted.