multi list / categories

2 posts by 2 authors in: Forums > CMS Builder
Last Post: October 8, 2013   (RSS)

By rez - October 3, 2013 - edited: October 3, 2013

i have a category setup with categories in one editor and projects in another. in projects, i use a checkbox list to add projects to multiple categories. sort of like tags.  it works well with my usual setup of selecting a category and using:

// if there is a category selected, make the multi selections
if ($selectedCategory):
list($itemsRecords, $itemsMetaData) = getRecords(array(
'tableName' => 'projects',
'where' => "category LIKE '%\t{$selectedCategory['num']}\t%'",
'perPage' => '16',
//'debugSql' =>'true'
));
endif;

but in a new portfolio im making, i would like the landing page when nothing is selected yet (master / details same page):

<?php if (!$selectedCategory): ?>




<?php $counter = 1; ?>

//portfolio preview 7 project per category


<ul class="mycarousel"><?php $counter = 1; ?>
   <?php foreach ($projectsRecords as $record): ?>
        <?php if($counter < 7) : ?>
             <?php if($record['category']==$category['num']): ?>
                 <li>
                   <div class="item">
                     <?php foreach ($record['image'] as $upload): ?>
                         <?php if ($upload['hasThumbnail']): ?>
                              <img src="<?php echo $upload['thumbUrlPath4'] ?>" alt="" />
                         <?php endif ?>
                     <?PHP endforeach ?>                                                           
                     <div class="item_title"><div class="type audio"></div><a href="#"><?php echo $record['title'] ?></a></div>
                      <div class="item_descr"><?php echo maxWords($record['content'], 6); ?> <a href="#">Read more...</a></div>
                  </div>
             </li>
             <?php endif ?>


      <?php $counter++ ?>


      <?php endif ?>
   <?PHP endforeach ?>
                                                                                                                                                      
 </ul>

<?php endif ?>

But that doesn't work because of the multiple categories each project may be in. $record['category'] will not equal $category['num'])   How can i show a number of projects on a page for each category (check boxes are true) when no category is selected / in the url? I hope i can do this without too may loops lagging my page :(