Parcourir la source

:recycle: return exhibition and events as list | ASC sorting for future

tags/0.9.0
j il y a 4 ans
Parent
révision
50839897d3

+ 3
- 2
plugins/cia-endpoints/includes/class.make-endpoint.php Voir le fichier

@@ -104,12 +104,13 @@ class Make_Endpoint_For extends WP_REST_Controller {
104 104
             // Sticky
105 105
             $filtered[sticky] = get_post_meta( $item->ID, 'is_sticky', true );
106 106
 
107
-            // $filtered[relatedto] = p2p_related_to( $item->ID, $item->post_type );
108
-
109 107
             if($item->post_type == 'page') {
110 108
                 $filtered[content] = $item->post_content;
111 109
                 $collection[$item->post_name] = $filtered;
112 110
             }
111
+            else if($item->post_type == 'exhibition' || $item->post_type == 'event') {
112
+                array_push($collection, $filtered);
113
+            }
113 114
             else {
114 115
                 $collection[$item->ID] = $filtered;
115 116
             }

+ 1
- 1
plugins/cia-endpoints/includes/class.make-sortby.php Voir le fichier

@@ -127,7 +127,7 @@ class Make_Sort_By extends WP_REST_Controller {
127 127
             JOIN wp_postmeta AS starts
128 128
             ON (starts.post_id = wp_posts.ID AND starts.meta_key = %s AND starts.meta_value >= %s)
129 129
             WHERE post_type = %s AND post_status = 'publish'
130
-            ORDER BY starts.meta_value DESC",
130
+            ORDER BY starts.meta_value ASC",
131 131
             $start, $time, $this->post_type
132 132
         ));
133 133
         wp_reset_postdata();

+ 12
- 5
vue-theme/src/pages/list.vue Voir le fichier

@@ -13,7 +13,8 @@
13 13
 
14 14
         .posts(v-if="posts && loaded" :class="{ 'is-grid': grid }")
15 15
             section(v-for="(post, i) in posts" :key="post.slug").shadow.post
16
-                card(:content="post" :type="type" :wide="type == 'exhibitions' && i > 1 || type == 'events' && i > 1 ")
16
+                p {{ post }}
17
+            //-     card(:content="post" :type="type" :wide="type == 'exhibitions' && i > 1 || type == 'events' && i > 1 ")
17 18
 
18 19
         footer
19 20
             p {{ `${type} count: ${Object.values(posts).length}` }}
@@ -69,20 +70,26 @@ export default {
69 70
              * so if a sortBy is specified we return it sorted or
70 71
              * we fail over to sorted by date
71 72
              */
72
-            return this.sortBy ? this[`all${type}`] : sortedByRecent
73
+            let returnList = sortedByRecent
74
+            if(this.sortBy && sortTypes.includes(this.sortBy)) {
75
+                returnList = this[`all${type}`]
76
+            }
77
+            if(['exhibitions', 'events'].includes(this.type)) {
78
+                returnList = this[`all${type}`]
79
+            }
80
+            return returnList
73 81
         },
74 82
     },
75 83
     methods: {
76 84
         getPosts() {
77 85
             // Sorting
78 86
             let sort = this.sortBy ? this.sortBy : this.$route.path.split('/').pop()
87
+            // !: BUG
88
+            // if(this.type !== sort || !Object.values(sortTypes).includes(sort)) sort = null
79 89
             if(Object.values(sortTypes).includes(sort)) {
80 90
                 console.log('trying to sort by:', sort)
81 91
                 console.log(`sortTypes includes ${sort}:`, Object.values(sortTypes).includes(sort))
82 92
             }
83
-            // Is this a sort type?
84
-            // !: BUG
85
-            // if(this.type !== sort || !Object.values(sortTypes).includes(sort)) sort = null
86 93
             
87 94
             // Don't dispatch if there's no type
88 95
             if(this.type && this.dispatchName) {

+ 1
- 0
vue-theme/src/store/modules/exhibition.js Voir le fichier

@@ -1,4 +1,5 @@
1 1
 import api from '../../utils/api'
2
+import { sortTypes } from '../../utils/helpers'
2 3
 
3 4
 const state = {
4 5
     all: [],

Chargement…
Annuler
Enregistrer