diplaying products in multiple categories

3 posts by 2 authors in: Forums > CMS Builder
Last Post: November 17, 2011   (RSS)

By rez - November 16, 2011 - edited: November 16, 2011

I have a category menu setup. So far, its all one level.

I have products in another editor using advanced list, num for value, breadcrumb for label.

I have my categories showing up in a list and showing ok in the address bar, like:
mysite.com/portfolio.php?POP-Displays-18

BUT each item can be assigned to multiple categories (checkboxes) in the product editor.

viewer:
list($categoryRecords, $selectedCategory) = getCategories(array(
'tableName' => 'project_cats',
//'selectedCategoryNum' => '', // defaults to getNumberFromEndOfUrl()
'categoryFormat' => 'showall', // showall, onelevel, twolevel
));
list($itemsRecords, $itemsMetaData) = getRecords(array(
'tableName' => 'projects',
'where' => "category LIKE '%\t1\t%' ",
// 'debugSql' =>'true'
));




<?php if ($selectedCategory): ?>
<?php foreach ($itemsRecords as $itemRecord): ?>

<!--Output items in this category -->
<ul>
<?php if ($itemRecord['category'] == $selectedCategory['num']): ?>
<li><?php echo $itemRecord['client:label'];?><br /> //another list
<?php echo $itemRecord['title'];?></li>
<?php endif ?>
</ul>

<!--/Ouptut items in this category -->
<?php endforeach ?>

<!-- /Output Categories -->

<?php endif ?>


<div id="sidebar">

<ul class="style6">
<?php foreach ($categoryRecords as $categoryRecord): ?>
<?php echo $categoryRecord['_listItemStart'] ?>
<?php if ($categoryRecord['_isSelected']): ?>
<strong>
<?php if (!$categoryRecord['_hasChild']):?>
<a href="<?php echo $categoryRecord['_link'] ?>">
<?php endif; ?>
<?php echo $categoryRecord['name'] ?>
<?php if (!$categoryRecord['_hasChild']):?>
</a>
<?php endif; ?>
</strong>
<?php else: ?>
<?php if (!$categoryRecord['_hasChild']):?>
<a href="<?php echo $categoryRecord['_link'] ?>">
<?php endif; ?>
<?php echo $categoryRecord['name'] ?>
<?php if (!$categoryRecord['_hasChild']):?>
</a>
<?php endif; ?>
<?php endif ?>
<?php echo $categoryRecord['_listItemEnd'] ?>
<?php endforeach; ?>
</ul>
</div>


Unfortunately, I am not getting anything to display when clicking on categories (and reloading same page as set in viewer urls). I am finding info that confuses me in the forum. That's where I found the list code and I'm not sure that it is correct.

I want to display all products assigned to the one category I click in the side bar, even know they might belong to several other categories as well.

thanks for any help.



dont know if this helps but clicking any category with debug on shows:

SELECT SQL_CALC_FOUND_ROWS `projects`.* FROM `cms_projects` as `projects` WHERE (category LIKE '% 1 %' ) AND projects.hidden = 0 ORDER BY client ASC

Re: [ross] diplaying products in multiple categories

By rez - November 17, 2011 - edited: November 17, 2011

I had a couple of issues going on from importing categories with a csv file. I ended up deleting them all and have this portfolio working with a different idea. thanks.