View Single Post
  #6  
Old May 10th, 2013, 09:11 AM
urbaniteuk urbaniteuk is offline
 
Join Date: Apr 2013
Posts: 120
Default

1. I was referring to this code:

Quote:
Originally Posted by Eric View Post
Hi

Try using this instead in your functions.php file:
PHP Code:
function dfr_get_brands_list($category) {
    global 
$wpdb;
    
$cat_query "";
    if (
$category) { 
        
$in = array();
        
$in[] = $category->id;
        if (!empty(
$category->children)) {
            foreach (
$category->children as $child => $id) {
                
$in[] = $id;
            }
        }
        
$category_ids implode(","$in);
        
$cat_query "WHERE p2c.cat_id IN (".$category_ids.") "
    }
    
$brands $wpdb->get_results("
        SELECT brand, p2c.cat_id 
        FROM "
.$wpdb->prefix."dfr_shop_products AS p 
        INNER JOIN "
.$wpdb->prefix."dfr_shop_p2c AS p2c ON p.id = p2c.id 
        
$cat_query
        GROUP BY brand
    "
);
    
$list = array();
    foreach (
$brands as $brands) {
        
$brand trim($brands->brand);
        if (
$brand != "") {
            
$list[] = $brand;
        }
    }
    return 
$list;

And this in your view in the Factory:
HTML Code:
<ul>
<?php 
$brands = dfr_get_brands_list($category);
foreach ($brands as $brand) : ?>
  <li><a href="[server.url type='fullpage' query='brand=$brand']"><?php echo $brand; ?></a></li>
<?php endforeach; ?>
</ul>
Eric
Thanks for clarifying the other points.