From e0952de16619d685c2955ffbfb748d106337c8b3 Mon Sep 17 00:00:00 2001 From: danpros Date: Fri, 26 Jan 2024 19:23:15 +0700 Subject: [PATCH] Add new var --- system/admin/admin.php | 33 +++++++++++++++++++-------------- system/admin/views/user-draft.html.php | 2 +- system/includes/functions.php | 6 +++++- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/system/admin/admin.php b/system/admin/admin.php index 6892c1b..5a6520d 100644 --- a/system/admin/admin.php +++ b/system/admin/admin.php @@ -984,6 +984,7 @@ function find_draft_page($static = null) $post->md = $v['basename']; $post->slug = $url; $post->parent = null; + $post->parentSlug = null; // Get the contents and convert it to HTML $content = file_get_contents($post->file); @@ -1024,30 +1025,34 @@ function find_draft_subpage($static = null, $sub_static = null) foreach ($posts as $index => $v) { if (stripos($v['basename'], $sub_static . '.md') !== false) { - + $post = new stdClass; - + + $fd = str_replace('content/static/', '', dirname($v['dirname'])); + + $pr = explode('.', $fd); + if (isset($pr[1])) { + $ps = $pr[1]; + } else { + $ps = $fd; + } + // The static page URL $fn = explode('.', $v['filename']); if (isset($fn[1])) { $url = $fn[1]; } else { - $url= $v['filename']; + $url = $v['filename']; } - - if (is_null($static)) { - $parent = str_replace('content/static/', '', dirname($v['dirname'])); - $post->parent = $parent; - $post->url = site_url() . $parent . "/" . $url; - } else { - $post->parent = $static; - $post->url = site_url() . $static . "/" . $url; - } - + + $post->parent = $fd; + $post->parentSlug = $ps; + $post->url = site_url() . $ps . "/" . $url; + $post->file = $v['dirname'] . '/' . $v['basename']; $post->lastMod = strtotime(date('Y-m-d H:i:s', filemtime($post->file))); - + $post->md = $v['basename']; $post->slug = $url; diff --git a/system/admin/views/user-draft.html.php b/system/admin/views/user-draft.html.php index 291355d..33f4ff1 100644 --- a/system/admin/views/user-draft.html.php +++ b/system/admin/views/user-draft.html.php @@ -72,7 +72,7 @@


-

: Subpages

+

: Sub

diff --git a/system/includes/functions.php b/system/includes/functions.php index 6a8ebb9..a3e3ffa 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -560,6 +560,7 @@ function get_pages($pages, $page = 1, $perpage = 0) $post->md = $v['basename']; $post->slug = $url; $post->parent = null; + $post->parentSlug = null; // Get the contents and convert it to HTML $content = file_get_contents($post->file); @@ -628,7 +629,8 @@ function get_subpages($sub_pages, $page = 1, $perpage = 0) $post->md = $v['basename']; $post->slug = $url; - $post->parent = $static; + $post->parent = $fd; + $post->parentSlug = $static; // Get the contents and convert it to HTML $content = file_get_contents($post->file); @@ -1860,6 +1862,7 @@ function static_prev($prev) 'md' => $prev->md, 'slug' => $prev->slug, 'parent' => $prev->parent, + 'parentSlug' => $prev->parentSlug, 'file' => $prev->file, 'readTime' => $prev->readTime, 'lastMod' => $prev->lastMod @@ -1879,6 +1882,7 @@ function static_next($next) 'md' => $next->md, 'slug' => $next->slug, 'parent' => $next->parent, + 'parentSlug' => $next->parentSlug, 'file' => $next->file, 'readTime' => $next->readTime, 'lastMod' => $next->lastMod