Пример #1
0
            foreach ($items->child_cat as $key1 => $item) {
                ?>
	                            <div class="arrow"></div>
	                            <div class="child-cat-title">
	                                <?php 
                $caturl = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $item->virtuemart_category_id);
                ?>
	                                <a href="<?php 
                echo $caturl;
                ?>
" <?php 
                echo VmCategoriesHelper::parseTarget($options->target);
                ?>
>
	                                    <?php 
                echo VmCategoriesHelper::truncate($item->category_name, (int) $params->get('cat_sub_title_maxcharacs', 25));
                if ($params->get('cat_all_product') == 1) {
                }
                ?>
	                                </a>
	                            </div>
	                        <?php 
            }
        } else {
            ?>
	                        <p>
	                            <?php 
            echo JText::_('No sub-categories to show!');
            ?>
	                        </p>
	                    <?php 
Пример #2
0
    public static function getCategories($onlyPublished = true, $parentId = false, $childId = false, $keyword = "", $vendorId = false)
    {
        $categoryModel = VmModel::getModel('Category');
        $select = ' c.`virtuemart_category_id`, l.`category_description`, l.`category_name`, c.`ordering`, c.`published`, cx.`category_child_id`, cx.`category_parent_id`, c.`shared` ';
        $joinedTables = ' FROM `#__virtuemart_categories_' . VmConfig::$vmlang . '` l
				  JOIN `#__virtuemart_categories` AS c using (`virtuemart_category_id`)
				  LEFT JOIN `#__virtuemart_category_categories` AS cx
				  ON l.`virtuemart_category_id` = cx.`category_child_id` ';
        $where = array();
        if ($onlyPublished) {
            $where[] = " c.`published` = 1 ";
        }
        if ($parentId !== false) {
            $where[] = ' cx.`category_parent_id` = ' . (int) $parentId;
        }
        if ($childId !== false) {
            $where[] = ' cx.`category_child_id` = ' . (int) $childId;
        }
        if ($vendorId === false) {
            $vendorId = 1;
        }
        if ($vendorId != 1) {
            echo $vendorId;
            $where[] = ' (c.`virtuemart_vendor_id` = "' . (int) $vendorId . '" OR c.`shared` = "1") ';
        }
        if (!empty($keyword)) {
            $db = JFactory::getDBO();
            $keyword = '"%' . $db->escape($keyword, true) . '%"';
            //$keyword = $db->Quote($keyword, false);
            $where[] = ' ( l.`category_name` LIKE ' . $keyword . '
							   OR l.`category_description` LIKE ' . $keyword . ') ';
        }
        $whereString = '';
        if (count($where) > 0) {
            $whereString = ' WHERE ' . implode(' AND ', $where);
        } else {
            $whereString = 'WHERE 1 ';
        }
        $ordering = $categoryModel->_getOrdering();
        self::$_category_tree = $categoryModel->exeSortSearchListQuery(0, $select, $joinedTables, $whereString, 'GROUP BY virtuemart_category_id', $ordering);
        return self::$_category_tree;
    }