ソースを参照

feat: template update

igb 4 ヶ月 前
コミット
e2f0e8c7ae

+ 23 - 5
app/Http/Controllers/CollectionController.php

@@ -31,14 +31,14 @@ class CollectionController extends Controller
     public function detail($slug)
     {
 
-
         // Find the tag by either slug or id
-        $tag = SitePageTag::where('slug', $slug)
-            ->orWhere('id', $slug)
-            ->where('dist_id',getDistId())
+        $tag = SitePageTag::where('dist_id', getDistId())
+            ->where(function ($query) use ($slug) {
+                $query->where('slug', $slug)
+                    ->orWhere('id', $slug);
+            })
             ->first();
 
-
         if (!$tag) {
             return response()->json(['message' => '标签未找到'], 404);
         }
@@ -47,10 +47,28 @@ class CollectionController extends Controller
         // 获取关联的 pages
         $pages = $tag->pages()->get();
 
+
+        // 构建导航数据 开始
+        $breadcrumbs = [
+            [
+                'url' => '/',
+                'name' => 'Home',
+            ]
+        ];
+
+
+        $breadcrumbs[] = [
+            'url' => '#',
+            'name' => $tag->name,
+        ];
+
+        // 构建导航数据 结束
+
         //模板支持多级目录,需要目录符号
         $output = LiquidRenderer::render('collection_list.liquid', [
             'tag' => $tag,
             'pages' => $pages,
+            'breadcrumbs' => $breadcrumbs,
         ]);
 
         return response($output);

+ 15 - 1
app/Http/Controllers/ContactController.php

@@ -18,10 +18,24 @@ class ContactController extends Controller
 
     function create()
     {
+        // 构建导航数据 开始
+        $breadcrumbs = [
+            [
+                'url' => '/',
+                'name' => 'Home',
+            ]
+        ];
+
+        $breadcrumbs[] = [
+            'url' => '#',
+            'name' => 'Contact Us',
+        ];
+
 
         //模板支持多级目录,需要目录符号
         $output = LiquidRenderer::render('contact_create.liquid', [
-            'csrf_token' => csrf_token()
+            'csrf_token' => csrf_token(),
+            'breadcrumbs' => $breadcrumbs,
         ]);
 
         return response($output);

+ 0 - 1
app/Http/Controllers/HomeController.php

@@ -12,7 +12,6 @@ class HomeController extends Controller
 
     }
 
-
     public function index()
     {
 

+ 62 - 5
app/Http/Controllers/PageController.php

@@ -4,7 +4,7 @@ namespace App\Http\Controllers;
 
 use Illuminate\Http\Request;
 use App\Services\LiquidRenderer;
-use App\Models\DistPages;
+use App\Models\SitePage;
 class PageController extends Controller
 {
 
@@ -22,7 +22,7 @@ class PageController extends Controller
      */
     public function list()
     {
-        $pages = DistPages::paginate(10)->where('dist_id', getDistId())->where('status', '1'); // 每页显示10个页面
+        $pages = SitePage::paginate(10)->where('dist_id', getDistId())->where('status', '1'); // 每页显示10个页面
         return $this->liquidRenderer->render('pages.list', ['pages' => $pages]);
     }
 
@@ -35,19 +35,76 @@ class PageController extends Controller
     public function detail($slug)
     {
 
-        $page = DistPages::where('status', '1')->where('dist_id', getDistId())->where('slug', $slug)->first();
+
+        $page = SitePage::where('status', '1')->where('dist_id', getDistId())->where('slug', $slug)->orWhere('id', $slug)->first();
+
 
         // 如果没有找到且是数字,通过 id 获取页面
         if (!$page) {
             if (is_numeric($slug))
             {
-                $page = DistPages::where('status', '1')->where('id', $slug)->firstOrFail();
+                $page = SitePage::where('status', '1')->where('dist_id', getDistId())->where('id', $slug)->firstOrFail();
             }
             else{
                 abort(404);
             }
         }
 
-        return $this->liquidRenderer->render('pages_detail.liquid', ['page' => $page]);
+        $previousPage = SitePage::where('dist_id', getDistId())
+            ->where('status', '1')
+            ->where('id', '<', $page->id)
+            ->orderBy('id', 'desc')
+            ->first();
+
+        $nextPage = SitePage::where('dist_id', getDistId())
+            ->where('status', '1')
+            ->where('id', '>', $page->id)
+            ->orderBy('id', 'asc')
+            ->first();
+
+        // 创建分页数据结构
+        $paginator = [
+            'previous_page' => $previousPage ? true : false, // 是否有上一页
+            'previous_page_url' => $previousPage ? "/pages/" . ($previousPage->slug ?: $previousPage->id) : null, // 上一页的 URL
+            'next_page' => $nextPage ? true : false, // 是否有下一页
+            'next_page_url' => $nextPage ? "/pages/" . ($nextPage->slug ?: $nextPage->id) : null // 下一页的 URL
+        ];
+
+
+        // 构建导航数据 开始
+        $breadcrumbs = [
+            [
+                'url' => '/',
+                'name' => 'Home',
+            ]
+        ];
+
+        if ($page->tags->isNotEmpty()) {
+            $tag = $page->tags->first();
+            $breadcrumbs[] = [
+                'url' => $tag->slug ? "/collections/{$tag->slug}" : "/collections/{$tag->id}",
+                'name' => $tag->name,
+            ];
+        }
+
+        $breadcrumbs[] = [
+            'url' => '#',
+            'name' => $page->title,
+        ];
+        // 构建导航数据 结束
+
+        $template_file ='pages_detail.liquid';
+
+        if(!epmty($page->template_file ))
+        {
+            $template_file=$page->template_file;
+        }
+        return $this->liquidRenderer->render('pages_detail.liquid',
+            [
+                'page' => $page,
+                'breadcrumbs' => $breadcrumbs,
+                'paginator' => $paginator,
+
+            ]);
     }
 }

+ 36 - 1
app/Http/Controllers/ProductController.php

@@ -59,11 +59,26 @@ class ProductController extends Controller
             ), // 每页的 URL
         ];
 
+        // 构建导航数据 开始
+        $breadcrumbs = [
+            [
+                'url' => '/',
+                'name' => 'Home',
+            ]
+        ];
+
+
+        $breadcrumbs[] = [
+            'url' => '#',
+            'name' => $category->name,
+        ];
+
         // 渲染模板并传递数据
         return $this->liquidRenderer->render('products_categories.liquid', [
             'category' => $category, // 分类名称
             'products' => $products,           // 分类下的产品
             'paginator' => $paginator, // 分页信息
+            'breadcrumbs' => $breadcrumbs,
         ]);
 
     }
@@ -78,12 +93,32 @@ class ProductController extends Controller
     {
         $product = DistProduct::getProduct($id);
 
+        // 构建导航数据 开始
+        $breadcrumbs = [
+            [
+                'url' => '/',
+                'name' => 'Home',
+            ]
+        ];
+
+        $category=$product->distProductCategory;
+
+        $breadcrumbs[] = [
+            'url' => "/products/{$category->name}",
+            'name' => $category->name,
+        ];
+
+        $breadcrumbs[] = [
+            'url' => '#',
+            'name' => $product->title,
+        ];
 
 
         return $this->liquidRenderer->render('products_detail.liquid',
             [
                 'product' => $product,
-                'csrf_token' => csrf_token()
+                'csrf_token' => csrf_token(),
+                'breadcrumbs' => $breadcrumbs,
             ]);
     }
 }

+ 26 - 3
app/Http/Controllers/VideoController.php

@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
 
 use Illuminate\Http\Request;
 use App\Services\LiquidRenderer;
+use App\Models\DistVideo ;
 class VideoController extends Controller
 {
     protected $liquidRenderer;
@@ -20,7 +21,7 @@ class VideoController extends Controller
      */
     public function index()
     {
-        $videos = Video::paginate(10)->where('dist_id', getDistId()); // 每页显示10个视频
+        $videos = DistVideo::paginate(10)->where('dist_id', getDistId()); // 每页显示10个视频
         return $this->liquidRenderer->render('videos.index', ['videos' => $videos]);
     }
 
@@ -32,7 +33,29 @@ class VideoController extends Controller
      */
     public function show($id)
     {
-        $video = Video::findOrFail($id);
-        return $this->liquidRenderer->render('videos.show', ['video' => $video]);
+
+        $video = DistVideo::findOrFail($id);
+
+        // 构建导航数据 开始
+        $breadcrumbs = [
+            [
+                'url' => '/',
+                'name' => 'Home',
+            ]
+        ];
+
+        $category=$video->distVideoCategory;
+
+        $breadcrumbs[] = [
+            'url' => "/videos/{$category->name}",
+            'name' => $category->name,
+        ];
+
+        $breadcrumbs[] = [
+            'url' => '#',
+            'name' => $video->title,
+        ];
+
+        return $this->liquidRenderer->render('videos.show', ['video' => $video, 'breadcrumbs' => $breadcrumbs]);
     }
 }

+ 0 - 12
app/Models/DistPages.php

@@ -1,12 +0,0 @@
-<?php
-
-namespace App\Models;
-
-use Illuminate\Database\Eloquent\Factories\HasFactory;
-use Illuminate\Database\Eloquent\Model;
-
-class DistPages extends Model
-{
-    use HasFactory;
-    protected $table = 'site_pages';
-}

+ 1 - 1
app/Models/SitePageTag.php

@@ -17,6 +17,6 @@ class SitePageTag extends Model
             'site_pages_tag_relationship',
             'tag_id',
             'pages_id'
-        )->where('status', 1);;
+        )->where('status', 1);
     }
 }

+ 129 - 0
resources/views/liquid/1/TechVista/pages_sp_default.liquid

@@ -0,0 +1,129 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<meta name="robots" content="index, follow">
+<meta name="author" content="Mietubl">
+<meta name="description" content="{{ page.seo_description }}">
+<meta name="keywords" content="{{page.seo_keywords}}">
+<title>{{page.seo_title}}</title>
+
+{% include '_header_css.liquid' %}
+</head>
+<body>
+
+<!-- MAIN WRAPPER -->
+<div class="body-wrap shop-default shop-cards shop-tech">
+    <div id="st-container" class="st-container">
+        <div class="st-pusher">
+            <div class="st-content">
+                <div class="st-content-inner">
+                    <!-- HEADER -->
+                    {% include '_header.liquid' %}
+                    <!-- END: HEADER -->
+                    <!-- BREADCRUMB -->
+                    <section class="slice sct-color-1">
+                        <div class="container">
+                            <div class="page-title">
+                                <div class="row align-items-center">
+                                    <div class="d-flex justify-content-end col-lg-12 col-12">
+                                        {% for  breadcrumb in breadcrumbs %}
+                                            <h2 class="heading heading-6 text-capitalize strong-500 mb-0">
+                                                <a href="{{ breadcrumb.url }}" class="link text-underline--none">
+                                                    &nbsp;
+                                                    {% if forloop.index == 1 %}
+                                                        <!-- 第一个 breadcrumb 使用 ion-ios-home 图标 -->
+                                                        <i class="ion-ios-home"></i>
+                                                    {% else %}
+                                                        <!-- 其它 breadcrumb 使用 ion-ios-arrow-forward 图标 -->
+                                                        <i class="ion-ios-arrow-forward"></i>
+                                                    {% endif %}
+                                                    {{ breadcrumb.name }}
+                                                </a>
+                                            </h2>
+                                        {% endfor %}
+                                    </div>
+                                </div>
+                            </div>
+                        </div>
+                    </section>
+                    <!-- END: BREADCRUMB -->
+                    <section class="slice sct-color-1">
+                        <div class="container">
+                            <section class="slice-sm sct-color-1">
+                                <div class="container container-xs">
+                                    <div class="block block-post">
+                                        <div class="block-body block-post-body">
+                                            <h1>
+                                                {{ page.title | raw }}
+                                            </h1>
+
+                                            {{page.content | raw }}
+
+                                        </div>
+                                    <!-- Comment form -->
+                                </div>
+                             </div>
+                    </section>
+                            <div class="pt-5">
+                                <nav aria-label="Product pagination">
+                                    <ul class="pagination pagination--style-2 justify-content-center">
+                                        <!-- Previous Page Link -->
+                                        {% if paginator.previous_page %}
+                                            <li class="page-item">
+                                                <a class="page-link" href="{{ paginator.previous_page_url }}" tabindex="-1">Previous</a>
+                                            </li>
+                                        {% else %}
+                                            <li class="page-item disabled">
+                                                <a class="page-link" href="#" tabindex="-1">Previous</a>
+                                            </li>
+                                        {% endif %}
+
+                                        <!-- Next Page Link -->
+                                        {% if paginator.next_page %}
+                                            <li class="page-item">
+                                                <a class="page-link" href="{{ paginator.next_page_url }}">Next</a>
+                                            </li>
+                                        {% else %}
+                                            <li class="page-item disabled">
+                                                <a class="page-link" href="#">Next</a>
+                                            </li>
+                                        {% endif %}
+                                    </ul>
+                                </nav>
+                            </div>
+                        </div>
+                    </section>
+
+                    <!-- FOOTER -->
+                    {% include '_footer.liquid' %}
+                </div>
+            </div>
+        </div><!-- END: st-pusher -->
+    </div><!-- END: st-container -->
+</div><!-- END: body-wrap -->
+<a href="#" class="back-to-top btn-back-to-top"></a>
+{% include '_footer_js.liquid' %}
+
+<!-- Isotope -->
+<script src="/static/js/isotope.min.js"></script>
+<script src="/static/js/imagesloaded.pkgd.min.js"></script>
+
+<!-- Deso Slide -->
+<script src="/static/js/jquery.desoslide.min.js"></script>
+<script>
+    $('#slideshow').desoSlide({
+        thumbs: $('#slideshow_thumbs .swiper-slide > a'),
+        thumbEvent: 'click',
+        first: 0,
+        effect: 'none',
+        overlay: 'none',
+        controls: {
+            show: false,
+            keys: false
+        },
+    });
+</script>
+</body>
+</html>