当前位置: 首页>>代码示例>>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;未经允许,请勿转载。