Category filter by another table

5 posts by 2 authors in: Forums > CMS Builder
Last Post: July 8, 2011   (RSS)

By ht1080z - July 6, 2011

Hi,

Building product catalog based on category menus when products are recorded in different table, i try to filter categories they have no related with recorded products, only for the menu structure and the same page when products displayed, show differently for the user.

Products only recorded on the last child of the category structure and when someone select from the menu any other category where is no products (or any other way to filter this...) showing only the selected category and his child's only and the related fields of the categories.

Look at the attached php file (trying this filter to work from the line 187). [:|]

Please advise if you have any suggestion,
Thank you in advance!
Attachments:

cat1_cmsb_panel.jpg 117K

products1.php 10K

Re: [Jason] Category filter by another table

By ht1080z - July 7, 2011 - edited: July 8, 2011

Hi Jason,

Thank you for your reply!

I try filter only the first level of the selected branch. See code below until now how. (the parentnum is not working.)

<?php foreach ($cat1Records as $cat1Record): ?>
<?php if ($cat1Record['_isSelected'] || $cat1Record['_isAncestorSelected'] && ($cat1Record['parentNum'] = $selected1Category['num'])): ?>
<a href="<?php echo $cat1Record['_link'] ?>"><?php echo $cat1Record['name']; ?></a>
<?php echo $cat1Record['content'] ?><br/>
<?php endif; ?>
<?php endforeach; ?>


Any suggestion on this?
Thanks again!

Re: [ht1080z] Category filter by another table

By Jason - July 8, 2011

Hi,

What's happening here is your using "=" which is an assignment operator instead of "==" which is for comparison.

Try this:

<?php foreach ($cat1Records as $cat1Record): ?>
<?php if (($cat1Record['_isSelected'] || $cat1Record['_isAncestorSelected'] ) && ($cat1Record['parentNum'] == $selected1Category['num'])): ?>
<a href="<?php echo $cat1Record['_link'] ?>"><?php echo $cat1Record['name']; ?></a>
<?php echo $cat1Record['content'] ?><br/>
<?php endif; ?>
<?php endforeach; ?>


This is actually a very common mistake (I make it all the time!)

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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

Re: [Jason] Category filter by another table

By ht1080z - July 8, 2011

Jason!

Thank for your support on this again! [:)]