当前位置: 首页>>代码示例>>PHP>>正文


PHP get_parent_category函数代码示例

本文整理汇总了PHP中get_parent_category函数的典型用法代码示例。如果您正苦于以下问题:PHP get_parent_category函数的具体用法?PHP get_parent_category怎么用?PHP get_parent_category使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_parent_category函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getMenu

 /**
  * 显示左边菜单,进行权限控制
  * @author huajie <banhuajie@163.com>
  */
 protected function getMenu()
 {
     $cate = M('Category')->where(array('status' => 1))->field('id,title,pid,allow_publish')->order('pid,sort')->select();
     $cate = list_to_tree($cate);
     //生成分类树
     //获取分类id
     $cate_id = I('param.cate_id');
     $this->cate_id = $cate_id;
     //是否展开分类
     $hide_cate = false;
     if (ACTION_NAME != 'recycle' && ACTION_NAME != 'draftbox' && ACTION_NAME != 'mydocument') {
         $hide_cate = true;
     }
     //生成每个分类的url
     foreach ($cate as $key => &$value) {
         $value['url'] = 'Article/index?cate_id=' . $value['id'];
         if ($cate_id == $value['id'] && $hide_cate) {
             $value['current'] = true;
         } else {
             $value['current'] = false;
         }
         if (!empty($value['_child'])) {
             $is_child = false;
             foreach ($value['_child'] as $ka => &$va) {
                 $va['url'] = 'Article/index?cate_id=' . $va['id'];
                 if (!empty($va['_child'])) {
                     foreach ($va['_child'] as $k => &$v) {
                         $v['url'] = 'Article/index?cate_id=' . $v['id'];
                         $v['pid'] = $va['id'];
                         $is_child = $v['id'] == $cate_id ? true : false;
                     }
                 }
                 //展开子分类的父分类
                 if ($va['id'] == $cate_id || $is_child) {
                     $is_child = false;
                     if ($hide_cate) {
                         $value['current'] = true;
                         $va['current'] = true;
                     } else {
                         $value['current'] = false;
                         $va['current'] = false;
                     }
                 } else {
                     $va['current'] = false;
                 }
             }
         }
     }
     //dump($cate);
     $this->assign('nodes', $cate);
     $this->assign('cate_id', $this->cate_id);
     //获取面包屑信息
     $nav = get_parent_category($cate_id);
     $this->assign('rightNav', $nav);
 }
开发者ID:xingluxin,项目名称:jianshen,代码行数:59,代码来源:CategoryController.class.php

示例2: getMenu

 /**
  * 显示左边菜单,进行权限控制
  * @author huajie <banhuajie@163.com>
  */
 protected function getMenu()
 {
     //获取动态分类
     $cate_auth = AuthGroupModel::getAuthCategories(UID);
     //获取当前用户所有的内容权限节点
     $cate_auth = $cate_auth == null ? array() : $cate_auth;
     $cate = D('Category')->where(array('status' => 1))->field('id,title,pid,allow_publish')->order('pid,sort')->select();
     //没有权限的分类则不显示
     if (!IS_ROOT) {
         foreach ($cate as $key => $value) {
             if (!in_array($value['id'], $cate_auth)) {
                 unset($cate[$key]);
             }
         }
     }
     $cate = list_to_tree($cate);
     //生成分类树
     //获取分类id
     $cate_id = I('param.cate_id');
     $this->cate_id = $cate_id;
     //是否展开分类
     $hide_cate = false;
     if (ACTION_NAME != 'recycle' && ACTION_NAME != 'draftbox' && ACTION_NAME != 'mydocument') {
         $hide_cate = true;
     }
     //生成每个分类的url
     foreach ($cate as $key => &$value) {
         $value['url'] = 'Article/index?cate_id=' . $value['id'];
         if ($cate_id == $value['id'] && $hide_cate) {
             $value['current'] = true;
         } else {
             $value['current'] = false;
         }
         if (!empty($value['_child'])) {
             $is_child = false;
             foreach ($value['_child'] as $ka => &$va) {
                 $va['url'] = 'Article/index?cate_id=' . $va['id'];
                 if (!empty($va['_child'])) {
                     foreach ($va['_child'] as $k => &$v) {
                         $v['url'] = 'Article/index?cate_id=' . $v['id'];
                         $v['pid'] = $va['id'];
                         $is_child = $v['id'] == $cate_id ? true : false;
                     }
                 }
                 //展开子分类的父分类
                 if ($va['id'] == $cate_id || $is_child) {
                     $is_child = false;
                     if ($hide_cate) {
                         $value['current'] = true;
                         $va['current'] = true;
                     } else {
                         $value['current'] = false;
                         $va['current'] = false;
                     }
                 } else {
                     $va['current'] = false;
                 }
             }
         }
     }
     $this->assign('nodes', $cate);
     $this->assign('cate_id', $this->cate_id);
     //获取面包屑信息
     $nav = get_parent_category($cate_id);
     $this->assign('rightNav', $nav);
     //获取回收站权限
     $this->assign('show_recycle', IS_ROOT || $this->checkRule('Admin/article/recycle'));
     //获取草稿箱权限
     $this->assign('show_draftbox', C('OPEN_DRAFTBOX'));
     //获取审核列表权限
     $this->assign('show_examine', IS_ROOT || $this->checkRule('Admin/article/examine'));
 }
开发者ID:terrydeng,项目名称:beimeibang1205,代码行数:76,代码来源:ArticleController.class.php

示例3: index

 /**
  * 分类文档列表页
  * @param integer $cate_id 分类id
  * @param integer $model_id 模型id
  * @param integer $position 推荐标志
  * @param integer $group_id 分组id
  */
 public function index()
 {
     $cate_id = I('cate_id');
     $model_id = I('model_id', null);
     $position = I('position', null);
     $group_id = I('group_id', null);
     //获取面包屑信息
     $nav = get_parent_category($cate_id);
     $this->assign('rightNav', $nav);
     if ($cate_id === null) {
         $cate_id = $this->cate_id;
     }
     if (!empty($cate_id)) {
         $pid = I('pid', 0);
         // 获取列表绑定的模型
         if ($pid == 0) {
             $models = get_category($cate_id, 'model');
             // 获取分组定义
             $groups = get_category($cate_id, 'groups');
             if ($groups) {
                 $groups = parse_field_attr($groups);
             }
         } else {
             // 子文档列表
             $models = get_category($cate_id, 'model_sub');
         }
         if (is_null($model_id) && !is_numeric($models)) {
             // 绑定多个模型 取基础模型的列表定义
             $model = M('Model')->getByName('document');
         } else {
             $model_id = $model_id ?: $models;
             //获取模型信息
             $model = M('Model')->getById($model_id);
             if (empty($model['list_grid'])) {
                 $model['list_grid'] = M('Model')->getFieldByName('document', 'list_grid');
             }
         }
         $this->assign('model', explode(',', $models));
     } else {
         $site_id = $this->site_id;
         $cates = M("Category")->where("site_id = {$site_id}")->getField('id', true);
         // 获取基础模型信息
         $model = M('Model')->getByName('document');
         $model_id = null;
         if (empty($cates)) {
             $cate_id = array('in', array(null));
         } else {
             $cate_id = array('in', $cates);
         }
         $this->assign('model', null);
     }
     if ($model['name'] == 'single') {
         $document_id = M('Document')->where("category_id={$cate_id}")->getField('id');
         $data = array();
         if ($document_id) {
             // 获取详细数据
             $Document = D('Document');
             $data = $Document->detail($document_id);
         } else {
             $data['pid'] = 0;
             $data['category_id'] = $cate_id;
             $data['model_id'] = $model_id;
         }
         $this->assign('data', $data);
         $this->assign('model_id', $data['model_id']);
         $this->assign('model', $model);
         //获取表单字段排序
         $fields = get_model_attribute($model['id']);
         $this->assign('fields', $fields);
         //获取当前分类的文档类型
         $this->assign('type_list', get_type_bycate($data['category_id']));
         $this->meta_title = '编辑内容';
         $this->display('Profile/Article/edit');
     } else {
         //解析列表规则
         $fields = array();
         $grids = preg_split('/[;\\r\\n]+/s', trim($model['list_grid']));
         foreach ($grids as &$value) {
             // 字段:标题:链接
             $val = explode(':', $value);
             // 支持多个字段显示
             $field = explode(',', $val[0]);
             $value = array('field' => $field, 'title' => $val[1]);
             if (isset($val[2])) {
                 // 链接信息
                 $value['href'] = $val[2];
                 // 搜索链接信息中的字段信息
                 preg_replace_callback('/\\[([a-z_]+)\\]/', function ($match) use(&$fields) {
                     $fields[] = $match[1];
                 }, $value['href']);
             }
             if (strpos($val[1], '|')) {
                 // 显示格式定义
//.........这里部分代码省略.........
开发者ID:slpi1,项目名称:onethink_multi_site,代码行数:101,代码来源:ArticleController.class.php

示例4: checkName

 /**
  * 检查标识是否已存在(只需在同一根节点下不重复)
  * @param string $name
  * @return true无重复,false已存在
  * @author huajie <banhuajie@163.com>
  */
 protected function checkName()
 {
     $name = I('post.name');
     $category_id = I('post.category_id', 0);
     $id = I('post.id', 0);
     $map = array('name' => $name, 'id' => array('neq', $id), 'status' => array('neq', -1));
     $category = get_category($category_id);
     if ($category['pid'] == 0) {
         $map['category_id'] = $category_id;
     } else {
         $parent = get_parent_category($category['id']);
         $root = array_shift($parent);
         $map['category_id'] = array('in', D("Category")->getChildrenId($root['id']));
     }
     $res = $this->where($map)->getField('id');
     if ($res) {
         return false;
     }
     return true;
 }
开发者ID:hanxiansen,项目名称:onethink,代码行数:26,代码来源:DocumentModel.class.php

示例5: getMenu

 /**
  * 显示左边菜单,进行权限控制
  * @author huajie <banhuajie@163.com>
  */
 protected function getMenu()
 {
     //获取动态分类
     $cate_auth = AuthGroupModel::getAuthCategories(UID);
     //获取当前用户所有的内容权限节点
     $cate_auth = $cate_auth == null ? array() : $cate_auth;
     $cate = M('Category')->where(array('status' => 1))->field('id,title,pid,allow_publish')->order('pid,sort')->select();
     //没有权限的分类则不显示
     if (!IS_ROOT) {
         foreach ($cate as $key => $value) {
             if (!in_array($value['id'], $cate_auth)) {
                 unset($cate[$key]);
             }
         }
     }
     $cate = list_to_tree($cate);
     //生成分类树
     //获取分类id
     $cate_id = I('param.cate_id');
     $this->cate_id = $cate_id;
     //是否展开分类
     $hide_cate = false;
     if (ACTION_NAME != 'recycle' && ACTION_NAME != 'draftbox' && ACTION_NAME != 'mydocument') {
         $hide_cate = true;
     }
     //生成每个分类的url
     foreach ($cate as $key => &$value) {
         $value['url'] = 'Article/index?cate_id=' . $value['id'];
         if ($cate_id == $value['id'] && $hide_cate) {
             $value['current'] = true;
         } else {
             $value['current'] = false;
         }
         if (!empty($value['_child'])) {
             $is_child = false;
             foreach ($value['_child'] as $ka => &$va) {
                 $va['url'] = 'Article/index?cate_id=' . $va['id'];
                 if (!empty($va['_child'])) {
                     foreach ($va['_child'] as $k => &$v) {
                         $v['url'] = 'Article/index?cate_id=' . $v['id'];
                         $v['pid'] = $va['id'];
                         $is_child = $v['id'] == $cate_id ? true : false;
                     }
                 }
                 //展开子分类的父分类
                 if ($va['id'] == $cate_id || $is_child) {
                     $is_child = false;
                     if ($hide_cate) {
                         $value['current'] = true;
                         $va['current'] = true;
                     } else {
                         $value['current'] = false;
                         $va['current'] = false;
                     }
                 } else {
                     $va['current'] = false;
                 }
             }
         }
     }
     $this->assign('nodes', $cate);
     $this->assign('cate_id', $this->cate_id);
     //获取面包屑信息
     $nav = get_parent_category($cate_id);
     $this->assign('rightNav', $nav);
     //获取回收站权限
     $this->assign('show_recycle', IS_ROOT || $this->checkRule('Admin/article/recycle'));
     //获取草稿箱权限
     $this->assign('show_draftbox', C('OPEN_DRAFTBOX'));
     $this->group_id = $_SESSION["onethink_admin"]["user_auth"]["group_id"];
     if (is_administrator($uid)) {
         $this->group_id = 1;
     }
     $this->assign('groupId', $this->group_id);
     $map_sh['status'] = 2;
     $map_sh['bianji_status'] = 0;
     $sh_count = M('Document')->where($map_sh)->count();
     $_SESSION["menu_nums"]["待编辑审核"] = $sh_count;
     $map_wd['uid'] = UID;
     $map_wd['status'] = array("eq", 0);
     $wd_count = M('Document')->where($map_wd)->count();
     $_SESSION["menu_nums"]["我的文档"] = $wd_count;
 }
开发者ID:Johnzero,项目名称:zero,代码行数:87,代码来源:ArticleController.class.php

示例6: mss_create_xml_product

    function mss_create_xml_product($id)
    {
        $product = new WC_Product($id);
        $weight = get_post_meta($id, '_weight', true);
        $weight = $weight ? $weight : "0.0";
        $buyPrice = get_post_meta($id, '_max_variation_regular_price', true) ? get_post_meta($id, '_max_variation_regular_price', true) : get_post_meta($id, '_regular_price', true);
        $buyPrice = $buyPrice ? $buyPrice * 100 : "0.0";
        $salePrice = get_post_meta($id, '_max_variation_price', true) ? get_post_meta($id, '_max_variation_price', true) : get_post_meta($id, '_price', true);
        $salePrice = $salePrice ? $salePrice * 100 : "0.0";
        $uuid = get_post_meta($id, '_woosklad_good_uuid', true);
        //echo $uuid."<br />";
        $categories = get_the_terms($id, 'product_cat');
        put_category_identity($categories);
        $parent = get_parent_category($categories);
        $parentUuid = get_option('woosklad_category_' . $parent . '_uuid') ? 'parentUuid="' . get_option('woosklad_category_' . $parent . '_uuid') . '"' : '';
        ob_start();
        ?>
      <good
        isSerialTrackable="false"
        weight="<?php 
        echo $weight;
        ?>
"
        salePrice="<?php 
        echo $salePrice;
        ?>
"
        buyPrice="<?php 
        echo $buyPrice;
        ?>
"
        name="<?php 
        echo $product->get_title();
        ?>
"
		    productCode="<?php 
        echo get_post_meta($id, '_sku', true);
        ?>
"
        <?php 
        echo $parentUuid;
        ?>
      >
        <code><?php 
        echo get_post_meta($id, '_sku', true);
        ?>
</code>
        <?php 
        if ($uuid) {
            ?>
          <uuid><?php 
            echo $uuid;
            ?>
</uuid>
        <?php 
        }
        ?>
	    </good>
    <?php 
        $xml = ob_get_contents();
        ob_get_clean();
        return $xml;
    }
开发者ID:systemo-biz,项目名称:woocommerce-mss,代码行数:63,代码来源:export-products.php


注:本文中的get_parent_category函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。