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:
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:
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: [rez] diplaying products in multiple categories
By ross - November 16, 2011
Hi rez
Thanks for posting! At first glance, everything looks good to me. I am curious if maybe swapping the % and the \t around in your LIKE code might do the trick.
Reason being is my understanding is % is a wildcard an \t is a tab. If you are storing things as a multi select, they are stored as tab separated so you would want the the wild card to be within the tabs. Give that shot.
If it doesn't get you going, I recommend commenting out that part for now so all your records appear. Then, have it display the value for your category field on each record just so you can double check what's actually being stored.
Does that make sense? Let me know what you think. Thanks!
Thanks for posting! At first glance, everything looks good to me. I am curious if maybe swapping the % and the \t around in your LIKE code might do the trick.
Reason being is my understanding is % is a wildcard an \t is a tab. If you are storing things as a multi select, they are stored as tab separated so you would want the the wild card to be within the tabs. Give that shot.
If it doesn't get you going, I recommend commenting out that part for now so all your records appear. Then, have it display the value for your category field on each record just so you can double check what's actually being stored.
Does that make sense? Let me know what you think. Thanks!
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com
Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com
Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/
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.