Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
diplaying products in multiple categories

 

 


rez
User

Nov 16, 2011, 10:41 AM

Post #1 of 3 (525 views)
Shortcut
diplaying products in multiple categories Can't Post

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:

Code
 
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:


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



(This post was edited by rez on Nov 16, 2011, 10:47 AM)


ross
Staff / Moderator


Nov 16, 2011, 2:29 PM

Post #2 of 3 (514 views)
Shortcut
Re: [rez] diplaying products in multiple categories [In reply to] Can't Post

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!
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Product Specialist
support@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/



rez
User

Nov 17, 2011, 11:26 AM

Post #3 of 3 (507 views)
Shortcut
Re: [ross] diplaying products in multiple categories [In reply to] Can't Post

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.


(This post was edited by rez on Nov 17, 2011, 5:49 PM)