explode looping too much

2 posts by 2 authors in: Forums > CMS Builder
Last Post: February 9, 2015   (RSS)

By Damon - February 9, 2015

HI Michael,

Can you try this code:

  // load record from 'products'
  list($productsRecords, $productsMetaData) = getRecords(array(
    'tableName'   => 'products',
    'where'       => whereRecordNumberInUrl(0),
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $productsRecord = @$productsRecords[0]; // get first record
  if (!$productsRecord) { dieWith404("Record not found!"); } // show error message if no record found

-------------------------------------------------------------------------------

                             <ul class="portfolio-details">
                                <li>
                                    <p><strong>Features:</strong></p>
                                    <ul class="list list-skills icons list-unstyled list-inline">                                    
                                    <?php $lines = explode("\n", $productsRecord['product_features']); ?>
                                    <?php foreach ($lines as $line) : ?>
                                     <?php if($line != ''): ?>
                                 
                                        <li><i class="fa fa-check-circle"></i><?php echo $line; ?></li>
                                        
                                    <?php endif; ?>
                                    <?php endforeach; ?>
                                    </ul>
                                </li>
                            </ul> 

What I did was get rid of the first foreachloop. Since this is a detail page record, it looked like the additional foreachloop was returning results for all records.

Let me know if this does the trick.

Thanks!

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/