]> git.bts.cx Git - cx.git/blobdiff - cx/lib/posts.php
Centralise permalink generation
[cx.git] / cx / lib / posts.php
index 3293ace514e3282867f390641c6cdd87053e9b3c..326d81c470585f90848e59d57b2ab2ffcbd339d8 100644 (file)
@@ -45,6 +45,11 @@ class Post {
                }
        }
 
                }
        }
 
+       public function get_permalink_path() {
+               $post_permalink = $this->is_page ? '/' . $this->slug : '/' . date('Y', $this->date) . '/' . date('m', $this->date) . '/' . $this->slug;
+               return $post_permalink;
+       }
+
        public function get_metadata() {
                $data = [];
 
        public function get_metadata() {
                $data = [];
 
@@ -99,7 +104,8 @@ function cx_posts_add_post($site_id, $title, $slug, $date, $page, $draft, $nav_i
                        post_data,
                        post_data_version)
                VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);';
                        post_data,
                        post_data_version)
                VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);';
-       cx_db_exec($sql, $site_id, $creation_time, $update_time, $slug, $date, $page, $draft, $nav_index, $title, $data, 1);
+       $id = cx_db_exec($sql, $site_id, $creation_time, $update_time, $slug, $date, $page, $draft, $nav_index, $title, $data, 1);
+       return $id;
 }
 
 function cx_posts_update_post($post_id, $title, $slug, $date, $page, $draft, $nav_index, $data) {
 }
 
 function cx_posts_update_post($post_id, $title, $slug, $date, $page, $draft, $nav_index, $data) {