dever 5 سال پیش
والد
کامیت
9bc8b62db2
3فایلهای تغییر یافته به همراه15 افزوده شده و 5 حذف شده
  1. 1 1
      app/collection/database/content.php
  2. 4 0
      app/collection/lib/Content.php
  3. 10 4
      app/collection/src/Api.php

+ 1 - 1
app/collection/database/content.php

@@ -179,7 +179,7 @@ return array
             'type' => 'all',
             'order' => array('reorder' => 'asc', 'id' => 'desc'),
             'page' => array(10, 'list'),
-            'col' => 'id,type,name,pic,info_id',
+            'col' => 'id,type,name,pic,info_id,page_id',
         ),
 
         'getAllByReorder' => array

+ 4 - 0
app/collection/lib/Content.php

@@ -29,6 +29,10 @@ class Content
 
 	public function getOne($data)
 	{
+        if ($data['page_id']) {
+            $page = Dever::db('collection/page')->one($data['page_id']);
+            $data['parent_page_id'] = $page['page_id'];
+        }
 		$type = Dever::db('collection/cate')->config['gettype'];
 		$table = $type[$data['type']]['table'];
 		if (!$table) {

+ 10 - 4
app/collection/src/Api.php

@@ -35,17 +35,23 @@ class Api
     # 获取合集下的分类
     public function category()
     {
+        $parent_page = Dever::input('parent_page');
+        $page = Dever::input('page');
         $where['info_id'] = Dever::input('id');
         $data['cate'] = Dever::db('collection/page')->main($where);
         if ($data['cate']) {
             $data['child'] = Dever::db('collection/page')->child($where);
             $content = Dever::db('collection/content')->child($where);
-            foreach ($data['child'] as $k => $v) {
-                if ($k == 0) {
-                    $data['child'][$k]['show'] = 1;
+            $data['show'] = array();
+            foreach ($data['cate'] as $k => $v) {
+                if ($v['id'] == $parent_page) {
+                    $data['show'][$v['id']] = 1;
                 } else {
-                    $data['child'][$k]['show'] = 2;
+                    $data['show'][$v['id']] = 2;
                 }
+            }
+            foreach ($data['child'] as $k => $v) {
+                
                 if (isset($content[$v['id']])) {
                     $data['child'][$k]['content'] = $content[$v['id']];
                 }