join

3 posts by 2 authors in: Forums > CMS Builder
Last Post: February 26, 2013   (RSS)

Hi Guys,

How can I change: Tags: <?php echo join(', ', getListLabels('work', 'tags', $record['tags'])); ?> into list items?

ie. Tags: <?php echo join('<li> ', getListLabels('work', 'tags', $record['tags'])'</li>'); ?>

Cheers,

Tim (toledoh.com.au)

By Dave - February 26, 2013

Hi Tim, 

More recent CMSB versions should create a pseudo-field called $record['tags:labels'] that contains the labels.  Can you check if that's defined? Just do this:

<?php showme($record); ?>

If it is, you can create list items like this (untested code): 

<?php foreach ($record['tags:labels'] as $label): ?>
  <li><?php echo htmlencode($label); ?></li>
<?php endforeach ?>

// or if you prefer straight php:
<?php foreach ($record['tags:labels'] as $label) { print "<li>" .htmlencode($label). "</li>\n"; } ?>

Use whichever is more readable to you.

Let me know if either of those work for you.  Thanks!

Dave Edis - Senior Developer
interactivetools.com