當前位置: 首頁>>代碼示例>>PHP>>正文


PHP HelperTreeCategories::setTemplate方法代碼示例

本文整理匯總了PHP中HelperTreeCategories::setTemplate方法的典型用法代碼示例。如果您正苦於以下問題:PHP HelperTreeCategories::setTemplate方法的具體用法?PHP HelperTreeCategories::setTemplate怎麽用?PHP HelperTreeCategories::setTemplate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在HelperTreeCategories的用法示例。


在下文中一共展示了HelperTreeCategories::setTemplate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: initFormAssociations

 public function initFormAssociations($obj)
 {
     $product = $obj;
     $data = $this->createTemplate($this->tpl_form);
     // Prepare Categories tree for display in Associations tab
     $root = Category::getRootCategory();
     $default_category = $this->context->cookie->id_category_products_filter ? $this->context->cookie->id_category_products_filter : Context::getContext()->shop->id_category;
     if (!$product->id || !$product->isAssociatedToShop()) {
         $selected_cat = Category::getCategoryInformations(Tools::getValue('categoryBox', array($default_category)), $this->default_form_language);
     } else {
         if (Tools::isSubmit('categoryBox')) {
             $selected_cat = Category::getCategoryInformations(Tools::getValue('categoryBox', array($default_category)), $this->default_form_language);
         } else {
             $selected_cat = Product::getProductCategoriesFull($product->id, $this->default_form_language);
         }
     }
     // Multishop block
     $data->assign('feature_shop_active', Shop::isFeatureActive());
     $helper = new HelperForm();
     if ($this->object && $this->object->id) {
         $helper->id = $this->object->id;
     } else {
         $helper->id = null;
     }
     $helper->table = $this->table;
     $helper->identifier = $this->identifier;
     // Accessories block
     $accessories = Product::getAccessoriesLight($this->context->language->id, $product->id);
     if ($post_accessories = Tools::getValue('inputAccessories')) {
         $post_accessories_tab = explode('-', Tools::getValue('inputAccessories'));
         foreach ($post_accessories_tab as $accessory_id) {
             if (!$this->haveThisAccessory($accessory_id, $accessories) && ($accessory = Product::getAccessoryById($accessory_id))) {
                 $accessories[] = $accessory;
             }
         }
     }
     $data->assign('accessories', $accessories);
     $product->manufacturer_name = Manufacturer::getNameById($product->id_manufacturer);
     $categories = array();
     foreach ($selected_cat as $key => $category) {
         $categories[] = $key;
     }
     $tree = new HelperTreeCategories('associated-categories-tree', 'Associated categories');
     $tree->setTemplate('tree_associated_categories.tpl')->setHeaderTemplate('tree_associated_header.tpl')->setRootCategory($root->id)->setUseCheckBox(true)->setUseSearch(true)->setSelectedCategories($categories);
     $data->assign(array('default_category' => $default_category, 'selected_cat_ids' => implode(',', array_keys($selected_cat)), 'selected_cat' => $selected_cat, 'id_category_default' => $product->getDefaultCategory(), 'category_tree' => $tree->render(), 'product' => $product, 'link' => $this->context->link, 'is_shop_context' => Shop::getContext() == Shop::CONTEXT_SHOP));
     $this->tpl_form_vars['custom_form'] = $data->fetch();
 }
開發者ID:,項目名稱:,代碼行數:47,代碼來源:


注:本文中的HelperTreeCategories::setTemplate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。