本文整理汇总了PHP中Category::getSubCategories方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::getSubCategories方法的具体用法?PHP Category::getSubCategories怎么用?PHP Category::getSubCategories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Category
的用法示例。
在下文中一共展示了Category::getSubCategories方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assignCategory
/**
* Assign template vars related to category
*/
protected function assignCategory()
{
// Assign category to the template
if ($this->category !== false && Validate::isLoadedObject($this->category)) {
$this->context->smarty->assign(array('path' => Tools::getPath($this->category->id, $this->product->name, true), 'category' => $this->category, 'subCategories' => $this->category->getSubCategories($this->context->language->id, true), 'id_category_current' => (int) $this->category->id, 'id_category_parent' => (int) $this->category->id_parent, 'return_category_name' => Tools::safeOutput($this->category->name)));
} else {
$this->context->smarty->assign('path', Tools::getPath((int) $this->product->id_category_default, $this->product->name));
}
$this->context->smarty->assign('categories', Category::getHomeCategories($this->context->language->id));
$this->context->smarty->assign(array('HOOK_PRODUCT_FOOTER' => Hook::exec('displayFooterProduct', array('product' => $this->product, 'category' => $this->category))));
}
示例2: renderContent
public function renderContent($args, $setting)
{
$t = array('category_id' => '');
$setting = array_merge($t, $setting);
$category = new Category($setting['category_id'], $this->langID);
$subCategories = $category->getSubCategories($this->langID);
$setting['title'] = $category->name;
$setting['subcategories'] = $subCategories;
$output = array('type' => 'sub_categories', 'data' => $setting);
return $output;
}
示例3: assignCategory
/**
* Assign template vars related to category.
*/
protected function assignCategory()
{
// Assign category to the template
if (($this->category === false || !Validate::isLoadedObject($this->category) || !$this->category->inShop() || !$this->category->isAssociatedToShop()) && Category::inShopStatic($this->product->id_category_default, $this->context->shop)) {
$this->category = new Category((int) $this->product->id_category_default, (int) $this->context->language->id);
}
$sub_categories = array();
if (Validate::isLoadedObject($this->category)) {
$sub_categories = $this->category->getSubCategories($this->context->language->id, true);
// various assignements before Hook::exec
$this->context->smarty->assign(array('category' => $this->category, 'subCategories' => $sub_categories, 'id_category_current' => (int) $this->category->id, 'id_category_parent' => (int) $this->category->id_parent, 'return_category_name' => Tools::safeOutput($this->category->getFieldByLang('name')), 'categories' => Category::getHomeCategories($this->context->language->id, true, (int) $this->context->shop->id)));
}
}
示例4: assignCategory
/**
* Assign template vars related to category
*/
protected function assignCategory()
{
// Assign category to the template
if ($this->category !== false && Validate::isLoadedObject($this->category) && $this->category->inShop() && $this->category->isAssociatedToShop()) {
$path = Tools::getPath($this->category->id, $this->product->name, true);
} elseif (Category::inShopStatic($this->product->id_category_default, $this->context->shop)) {
$this->category = new Category((int) $this->product->id_category_default);
if (Validate::isLoadedObject($this->category) && $this->category->active && $this->category->isAssociatedToShop()) {
$path = Tools::getPath((int) $this->product->id_category_default, $this->product->name);
}
}
if (!isset($path) || !$path) {
$path = Tools::getPath((int) $this->context->shop->id_category, $this->product->name);
}
// various assignements before Hook::exec
$this->context->smarty->assign(array('path' => $path, 'category' => $this->category, 'subCategories' => $this->category->getSubCategories($this->context->language->id, true), 'id_category_current' => (int) $this->category->id, 'id_category_parent' => (int) $this->category->id_parent, 'return_category_name' => Tools::safeOutput($this->category->name), 'categories' => Category::getHomeCategories($this->context->language->id, true, (int) $this->context->shop->id)));
$this->context->smarty->assign(array('HOOK_PRODUCT_FOOTER' => Hook::exec('displayFooterProduct', array('product' => $this->product, 'category' => $this->category))));
}
示例5: hookDisplayHome
public function hookDisplayHome($params)
{
if (!$this->isCached('blockhomecategories.tpl', $this->getCacheId('blockhomecategories'))) {
$categoryRoot = new Category((int) Configuration::get('BLK_FEATURED_CAT_ID'), $this->context->language->id, $this->context->shop->id);
$categoriesHome = $categoryRoot->getSubCategories($this->context->language->id, true, true);
array_splice($categoriesHome, (int) Configuration::get('BLK_FEATURED_CATEGORIES_NBR'));
foreach ($categoriesHome as $key => $item) {
if ($item['level_depth'] > 1) {
$categoryRoot = new Category($item['id_category'], $this->context->language->id, $this->context->shop->id);
$categoriesHome[$key]['childcategory'] = $categoryRoot->getSubCategories($this->context->language->id, true, true);
$categoriesHome[$key]['count_cild'] = count($categoriesHome[$key]['childcategory']);
array_splice($categoriesHome[$key]['childcategory'], (int) Configuration::get('BLK_FEATURED_CHILD_CATEGORIES_NBR'));
}
}
$this->smarty->assign(array('categories' => $categoriesHome, 'max_child_cats' => (int) Configuration::get('BLK_FEATURED_CHILD_CATEGORIES_NBR'), 'homeSize' => Image::getSize('medium_default')));
}
return $this->display(__FILE__, 'blockhomecategories.tpl', $this->getCacheId('blockhomecategories'));
}
示例6: hookLeftColumn
public function hookLeftColumn($params)
{
$this->setLastVisitedCategory();
$phpself = $this->context->controller->php_self;
$current_allowed_controllers = array('category');
if ($phpself != null && in_array($phpself, $current_allowed_controllers) && Configuration::get('BLOCK_CATEG_ROOT_CATEGORY') && isset($this->context->cookie->last_visited_category) && $this->context->cookie->last_visited_category) {
$category = new Category($this->context->cookie->last_visited_category, $this->context->language->id);
if (Configuration::get('BLOCK_CATEG_ROOT_CATEGORY') == 2 && !$category->is_root_category && $category->id_parent) {
$category = new Category($category->id_parent, $this->context->language->id);
} elseif (Configuration::get('BLOCK_CATEG_ROOT_CATEGORY') == 3 && !$category->is_root_category && !$category->getSubCategories($category->id, true)) {
$category = new Category($category->id_parent, $this->context->language->id);
}
} else {
$category = new Category((int) Configuration::get('PS_HOME_CATEGORY'), $this->context->language->id);
}
$cacheId = $this->getCacheId($category ? $category->id : null);
if (!$this->isCached('blockcategories.tpl', $cacheId)) {
$range = '';
$maxdepth = Configuration::get('BLOCK_CATEG_MAX_DEPTH');
if (Validate::isLoadedObject($category)) {
if ($maxdepth > 0) {
$maxdepth += $category->level_depth;
}
$range = 'AND nleft >= ' . (int) $category->nleft . ' AND nright <= ' . (int) $category->nright;
}
$resultIds = array();
$resultParents = array();
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT c.id_parent, c.id_category, cl.name, cl.description, cl.link_rewrite
FROM `' . _DB_PREFIX_ . 'category` c
INNER JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = ' . (int) $this->context->language->id . Shop::addSqlRestrictionOnLang('cl') . ')
INNER JOIN `' . _DB_PREFIX_ . 'category_shop` cs ON (cs.`id_category` = c.`id_category` AND cs.`id_shop` = ' . (int) $this->context->shop->id . ')
WHERE (c.`active` = 1 OR c.`id_category` = ' . (int) Configuration::get('PS_HOME_CATEGORY') . ')
AND c.`id_category` != ' . (int) Configuration::get('PS_ROOT_CATEGORY') . '
' . ((int) $maxdepth != 0 ? ' AND `level_depth` <= ' . (int) $maxdepth : '') . '
' . $range . '
AND c.id_category IN (
SELECT id_category
FROM `' . _DB_PREFIX_ . 'category_group`
WHERE `id_group` IN (' . pSQL(implode(', ', Customer::getGroupsStatic((int) $this->context->customer->id))) . ')
)
ORDER BY `level_depth` ASC, ' . (Configuration::get('BLOCK_CATEG_SORT') ? 'cl.`name`' : 'cs.`position`') . ' ' . (Configuration::get('BLOCK_CATEG_SORT_WAY') ? 'DESC' : 'ASC'));
foreach ($result as &$row) {
$resultParents[$row['id_parent']][] =& $row;
$resultIds[$row['id_category']] =& $row;
}
$blockCategTree = $this->getTree($resultParents, $resultIds, $maxdepth, $category ? $category->id : null);
$this->smarty->assign('blockCategTree', $blockCategTree);
if ((Tools::getValue('id_product') || Tools::getValue('id_category')) && isset($this->context->cookie->last_visited_category) && $this->context->cookie->last_visited_category) {
$category = new Category($this->context->cookie->last_visited_category, $this->context->language->id);
if (Validate::isLoadedObject($category)) {
$this->smarty->assign(array('currentCategory' => $category, 'currentCategoryId' => $category->id));
}
}
$this->smarty->assign('isDhtml', Configuration::get('BLOCK_CATEG_DHTML'));
if (file_exists(_PS_THEME_DIR_ . 'modules/blockcategories/blockcategories.tpl')) {
$this->smarty->assign('branche_tpl_path', _PS_THEME_DIR_ . 'modules/blockcategories/category-tree-branch.tpl');
} else {
$this->smarty->assign('branche_tpl_path', _PS_MODULE_DIR_ . 'blockcategories/category-tree-branch.tpl');
}
}
return $this->display(__FILE__, 'blockcategories.tpl', $cacheId);
}
示例7: getRandomSpecialCategory
public static function getRandomSpecialCategory($categoryid, $id_lang, $beginning = false, $ending = false)
{
$category = new Category($categoryid, Configuration::get('PS_LANG_DEFAULT'));
$subcategories = $category->getSubCategories($id_lang);
$subcategoryidArr = array();
foreach ($subcategories as $subcategory) {
$subcategoryidArr[] = $subcategory['id_category'];
}
$subcategoryidArr[] = $categoryid;
$cateid = implode(', ', $subcategoryidArr);
$currentDate = date('Y-m-d H:i:s');
$ids_product = self::_getProductIdByDate(!$beginning ? $currentDate : $beginning, !$ending ? $currentDate : $ending);
$groups = FrontController::getCurrentCustomerGroups();
$sqlGroups = count($groups) ? 'IN (' . implode(',', $groups) . ')' : '= 1';
$sql = 'SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`, p.`upc`,
i.`id_image`, il.`legend`, t.`rate`
FROM `' . _DB_PREFIX_ . 'product` p
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . (int) $id_lang . ')
LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . (int) $id_lang . ')
LEFT JOIN `' . _DB_PREFIX_ . 'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group` AND tr.`id_country` = ' . (int) Country::getDefaultCountryId() . '
AND tr.`id_state` = 0)
LEFT JOIN `' . _DB_PREFIX_ . 'tax` t ON (t.`id_tax` = tr.`id_tax`)
WHERE p.id_product IN (' . implode(', ', $ids_product) . ') and p.id_category_default in (' . implode(', ', $subcategoryidArr) . ')';
$rows = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
$results = array();
foreach ($rows as $row) {
$results[] = Product::getProductProperties($id_lang, $row);
}
return $results;
}
示例8: getSubCategories
function getSubCategories()
{
$session = Session::singletone();
$db = Database::singletone()->db();
$cid = Utils::pg("cid", 0);
$full = Utils::pg("full-tree", 0);
$this->_query->appendChild($this->_dom->createElement("category-id", $cid));
if ($cid < 0) {
$this->error("bad-arguments");
return;
}
$subs = Category::getSubCategories($cid);
foreach ($subs as $sub) {
$el = $this->_dom->createElement("category");
$el->appendChild($this->_dom->createElement("category-id", $sub['category_id']));
$el->appendChild($this->_dom->createElement("subcategories-count", $sub['subcategories_count']));
$el->appendChild($this->_dom->createElement("category-name", $sub['category_name']));
$el->appendChild($this->_dom->createElement("category-description", $sub['category_description']));
$el->appendChild($this->_dom->createElement("category-order", $sub['category_order']));
$el->appendChild($this->_dom->createElement('category-created', Utils::formatTime($sub['category_created'], Config::getUser($session->uid(), 'datetime-format'))));
$el->appendChild($this->_dom->createElement('creator-id', $sub['category_creator']));
$el->appendChild($this->_dom->createElement('creator-login', $sub['creator_login']));
$el->appendChild($this->_dom->createElement('creator-name', $sub['creator_name']));
$el->appendChild($this->_dom->createElement('creator-title', $sub['creator_title']));
$el->appendChild($this->_dom->createElement('photos-count', Category::getPhotosCount($sub['category_id'], false)));
$el->appendChild($this->_dom->createElement('total-photos-count', Category::getPhotosCount($sub['category_id'], true)));
$this->_response->appendChild($el);
}
$this->success();
}
示例9: renderWidgetSub_categoriesContent
public function renderWidgetSub_categoriesContent($args, $setting)
{
# validate module
unset($args);
$t = array('category_id' => '', 'limit' => '12');
$setting = array_merge($t, $setting);
// $nb = (int)$setting['limit'];
$category = new Category($setting['category_id'], $this->langID);
$subCategories = $category->getSubCategories($this->langID);
$setting['title'] = $category->name;
$setting['subcategories'] = $subCategories;
$output = array('type' => 'sub_categories', 'data' => $setting);
return $output;
}
示例10: hookAjaxCall
//.........这里部分代码省略.........
Configuration::updateValue('MEGAMENU_CATS', $SE_CATS);
}
$response = array('msg' => 'Item status has changed.', 'active' => $active);
}
echo Tools::jsonEncode($response);
} elseif ($action == "edit") {
$link = new MegaMenuClass((int) Tools::getValue('id'), Context::getContext()->cookie->id_lang);
echo Tools::jsonEncode($link);
} elseif ($action == "add") {
$link = new MegaMenuClass();
$link->active = 1;
$link->parent = (int) Tools::getValue('parent');
$link->parent_custom = Tools::getValue('custom') == 'true' ? 1 : 0;
$link->copyFromPost();
$link->add();
$response = array('id' => $link->id, 'parent' => $link->parent, 'name' => $link->name[Context::getContext()->cookie->id_lang], 'msg' => 'Menu item added.');
echo Tools::jsonEncode($response);
} elseif ($action == "saveedit") {
$link = new MegaMenuClass((int) Tools::getValue('id_megamenu'));
$link->copyFromPost();
$link->update();
$item = new MegaMenuClass((int) Tools::getValue('id_megamenu'), Context::getContext()->cookie->id_lang);
$response = array('msg' => 'Item modified.', 'item' => $item);
echo Tools::jsonEncode($response);
} elseif ($action == "copycms") {
$id_cms = array((int) Tools::getValue('id_cms'));
$cmslink[] = null;
$languages = Language::getLanguages(false);
foreach ($languages as $language) {
$cms = CMS::getLinks($language['id_lang'], $id_cms);
$cmslink += array('name_' . $language['id_lang'] => $cms[0]['meta_title'], 'title_' . $language['id_lang'] => $cms[0]['meta_title'], 'url_' . $language['id_lang'] => $cms[0]['link']);
}
if (!$errors) {
$link = new MegaMenuClass();
$link->active = 1;
$link->parent = (int) Tools::getValue('parentid');
$link->parent_custom = Tools::getValue('custom') == 'true' ? 1 : 0;
$link->copyFromPost($cmslink);
$link->add();
$response = array('id' => $link->id, 'parent' => $link->parent, 'name' => $link->name[Context::getContext()->cookie->id_lang], 'msg' => 'Cms item added.');
echo Tools::jsonEncode($response);
} else {
$error = array('error' => $errors);
echo Tools::jsonEncode($error);
}
} elseif ($action == "position") {
$csvAll = explode(",", Tools::getValue('csv'));
$total = count($csvAll) - 1;
for ($i = 0; $i < $total; $i++) {
$csv = explode("/", $csvAll[$i]);
Db::getInstance()->Execute('update `' . _DB_PREFIX_ . 'megamenu` set position = ' . (double) $csv[2] . ', parent = ' . $csv[1] . ', parent_custom = ' . ($csv[3] == 'true' ? 1 : 0) . ' where id_megamenu = ' . $csv[0]);
}
echo Tools::jsonEncode('Position update.');
} elseif ($action == "removeimage") {
$id = Tools::getValue('id');
if (file_exists(dirname(__FILE__) . "/images/" . $id . '.jpg')) {
unlink(dirname(__FILE__) . "/images/" . $id . '.jpg');
}
} elseif ($action == "gettree") {
$response = null;
$subs = null;
if (Tools::getValue('custom') == 'false') {
$cat = new Category((int) Tools::getValue('id'));
if (version_compare(_PS_VERSION_, '1.5.0.0') == +1) {
$subs = $this->getSubCategories($cat->id, Context::getContext()->cookie->id_lang, true);
} else {
$subs = $cat->getSubCategories($cookie->id_lang, true);
}
//get disable categories
$CATS = Configuration::get('MEGAMENU_CATS');
$UN_CATS = array();
$UN_CATS = unserialize($CATS);
}
$customLinks = MegaMenuClass::getCustomLinks(Tools::getValue('id'), Tools::getValue('custom'), Configuration::get('PS_LANG_DEFAULT'), $id_shop);
if (count($subs) > 0) {
$allLinks = array_merge($subs, $customLinks);
$this->aasort($allLinks, "position");
} else {
$allLinks = $customLinks;
}
//echo( print_r($allLinks) );
if ($allLinks) {
foreach ($allLinks as $link) {
if (isset($link['id_category'])) {
$children = MegaMenuClass::getNBchildren(false, $link['id_category']);
$response .= '<li class="' . ($children > 0 ? 'parent collapsed' : '') . '" data-id="' . $link['id_category'] . '" pos="' . $link['position'] . '">
<a class="caption ui-droppable ' . (is_array($UN_CATS) && in_array($link['id_category'], $UN_CATS) == true ? 'disable' : 'enable') . '" rel="' . $link['id_category'] . '">' . $link['name'] . '</a>
</li>';
} else {
$children = MegaMenuClass::getNBchildren(true, $link['id_megamenu']);
$response .= '<li class="custom ' . ($children > 0 ? 'parent collapsed' : '') . '" data-id="' . $link['id_megamenu'] . '" pos="' . $link['position'] . '">
<span class="custom-img"></span>
<a class="caption ui-droppable ' . ($link['active'] ? 'enable' : 'disable') . '" rel="' . $link['id_megamenu'] . '">' . $link['name'] . '</a>
</li>';
}
}
}
echo $response;
}
}
示例11: subsetNewsCategories
/**
*
* Returns an array of News article IDs belonging to the search categories
*/
protected function subsetNewsCategories()
{
global $_zp_CMS;
if (!is_array($this->category_list)) {
return false;
}
$cat = '';
$list = $_zp_CMS->getAllCategories();
if (!empty($list)) {
foreach ($list as $category) {
if (in_array($category['title'], $this->category_list)) {
$catobj = new Category($category['titlelink']);
$cat .= ' `cat_id`=' . $catobj->getID() . ' OR';
$subcats = $catobj->getSubCategories();
if ($subcats) {
foreach ($subcats as $subcat) {
$catobj = new Category($subcat);
$cat .= ' `cat_id`=' . $catobj->getID() . ' OR';
}
}
}
}
if ($cat) {
$cat = ' WHERE ' . substr($cat, 0, -3);
}
}
$sql = 'SELECT DISTINCT `news_id` FROM ' . prefix('news2cat') . $cat;
$result = query($sql);
$list = array();
if ($result) {
while ($row = db_fetch_assoc($result)) {
$list[] = $row['news_id'];
}
db_free_result($result);
}
return $list;
}
示例12: getWidgetVariables
public function getWidgetVariables($hookName = null, array $configuration = [])
{
$category = new Category((int) Configuration::get('PS_HOME_CATEGORY'), $this->context->language->id);
if (Configuration::get('BLOCK_CATEG_ROOT_CATEGORY') && isset($this->context->cookie->last_visited_category) && $this->context->cookie->last_visited_category) {
$category = new Category($this->context->cookie->last_visited_category, $this->context->language->id);
if (Configuration::get('BLOCK_CATEG_ROOT_CATEGORY') == 2 && !$category->is_root_category && $category->id_parent) {
$category = new Category($category->id_parent, $this->context->language->id);
} elseif (Configuration::get('BLOCK_CATEG_ROOT_CATEGORY') == 3 && !$category->is_root_category && !$category->getSubCategories($category->id, true)) {
$category = new Category($category->id_parent, $this->context->language->id);
}
}
return ['categories' => $this->getCategories($category), 'currentCategory' => $category->id];
}