Show list selections as separate items

6 posts by 2 authors in: Forums > CMS Builder
Last Post: November 19, 2013   (RSS)

I have a Tags section in my blog. For each post I select from a preloaded list of Tags. I want these to show on the website each selection in separate div.. instead of listing all together separated by ","

see here:

http://bit.ly/I1uJIh

here is my code for each post:

<?php foreach ($newsRecords as $record): ?>
<?php foreach ($record['image'] as $index => $upload): ?>

<div class="trendtile30 hidden" id="animate<?php echo $w++;?>">
<a href="/Trends/post.php?num=<?php echo htmlencode($record['num']) ?>">
<div class="trendtile" style="background-image:url(<?php echo $upload['urlPath'] ?>)">
 </div></a><div class="trendtext" style="height:30px;"><a href="/Trends/post.php?num=<?php echo htmlencode($record['num']) ?>"><?php echo htmlencode($record['title']) ?></a></div>
  <div class="tags">
<div class="tagbox">#<?php echo join(', ', $record['tag:labels']); ?></div>
 <div style="clear: both;"></div>
 
 </div>
 <div class="trendsocial">
  <div class="snshare1">Share</div>
<div class="snshare" style="background-image:url(../images/snshare_r1_c1.gif)"></div><div class="snshare" style="background-image:url(../images/snshare_r1_c3.gif)"></div><div class="snshare" style="background-image:url(../images/snshare_r1_c5.gif)"></div><div class="snshare" style="background-image:url(../images/snshare_r1_c7.gif)"></div>
<div style="clear: both;"></div>
</div>
  </div> 
 
  <?php endforeach ?>
  <?php endforeach ?>

I'm getting this error:

Notice: Undefined variable: newsRecord in /XXXXXXXXX/index.php on line 214 Warning: Invalid argument supplied for foreach() in XXXXXXXXXXX/index.php on line 214

By zip222 - November 19, 2013

There was a typo in the foreach line. try replacing that line and see if it works now.

Doesn't seem to be changed:

http://www.s2smedia.net/Trends/

heres what i have:


 <?php 
   // creates array of tag values and labels
   $tags = array_combine($record['tag:values'], $record['tag:labels']);
?>
<?php foreach ($tags as $tag_value => $tag_label): ?>
<div class="tagbox">#<?php echo $tag_label; ?></div><?php endforeach ?>

Sorry! never mind I got it!! thx