regionhalland/region-halland-plugin-current-page-and-child-pages

前端插件,返回当前页面和所有子页面

v1.2.0 2020-05-28 11:14 UTC

This package is not auto-updated.

Last update: 2024-09-28 07:37:09 UTC


README

如何使用Region Halland的插件"RhCurrentPageAndChildPages"

以下是如何使用插件"RhCurrentPageAndChildPages"的说明。

使用范围

此插件创建一个包含当前页面和所有子页面的数组

许可模型

此插件使用GPL-3.0许可模型。您可以通过随附的文件了解更多关于此许可模型的信息

LICENSE (https://regionhalland.visualstudio.com/public.RhWpPlugIns/_git/RhCurrentPageAndChildPages?path=%2FLICENSE&version=GBmaster)

安装和激活

A) Hämta pluginen via Git eller läs in det med Composer
B) Installera Region Hallands plugin i Wordpress plugin folder
C) Aktivera pluginet inifrån Wordpress admin

通过Git获取插件

git https://regionhalland.visualstudio.com/public.RhWpPlugIns/_git/RhCurrentPageAndChildPages

通过composer导入插件

以下两部分需要添加到您的composer文件中

存储库 = 插件存储的位置,在本例中是github

"repositories": [
  {
    "type": "vcs",
    "url": "https://regionhalland.visualstudio.com/public.RhWpPlugIns/_git/RhCurrentPageAndChildPages"
  },
],

要求 = 指定您想使用的插件版本,在本例中为1.0.0

注意!请调整以获取当前版本。

"require": {
  "regionhalland/region-halland-current-page-and-child-pages": "1.0.0"
},

通过"Blade"循环页面

@if(function_exists('get_region_halland_current_page_and_child_pages'))
    @php($myPages = get_region_halland_current_page_and_child_pages()) 
    @if(isset($myPages) && !empty($myPages['page_children']))
        <span>{{ $myPages['current_page']->post_title }}</span>
        @if (!empty($myPages['page_children']))
            @foreach ($myPages['page_children'] as $myChilds)
                <a href="{{ $myChilds->url }}">{{ $myChilds->post_title }}</a>
            @endforeach
        @endif
    @endif
@endif

数组可能的样子示例

array (size=2)
  'current_page' => 
    object(WP_Post)[6211]
      public 'ID' => int 9
      public 'post_author' => string '1' (length=1)
      public 'post_date' => string '2018-11-21 17:10:33' (length=19)
      public 'post_date_gmt' => string '2018-11-21 16:10:33' (length=19)
      public 'post_content' => string 'Etiam dictum enim eu tortor rhoncus' (length=35)
      public 'post_title' => string 'Etiam dictum enim' (length=17)
      public 'post_excerpt' => string '' (length=0)
      public 'post_status' => string 'publish' (length=7)
      public 'comment_status' => string 'closed' (length=6)
      public 'ping_status' => string 'closed' (length=6)
      public 'post_password' => string '' (length=0)
      public 'post_name' => string 'etiam-dictum-enim' (length=17)
      public 'to_ping' => string '' (length=0)
      public 'pinged' => string '' (length=0)
      public 'post_modified' => string '2018-11-30 16:39:40' (length=19)
      public 'post_modified_gmt' => string '2018-11-30 15:39:40' (length=19)
      public 'post_content_filtered' => string '' (length=0)
      public 'post_parent' => int 0
      public 'guid' => string 'http://exempel.se/?page_id=9' (length=34)
      public 'menu_order' => int 0
      public 'post_type' => string 'page' (length=4)
      public 'post_mime_type' => string '' (length=0)
      public 'comment_count' => string '0' (length=1)
      public 'filter' => string 'raw' (length=3)
  'page_children' => 
    array (size=2)
      0 => 
        object(WP_Post)[6402]
          public 'ID' => int 25
          public 'post_author' => string '1' (length=1)
          public 'post_date' => string '2018-11-22 11:34:55' (length=19)
          public 'post_date_gmt' => string '2018-11-22 10:34:55' (length=19)
          public 'post_content' => string 'Pretium sed tempor nisl ut accumsan' (length=35)
          public 'post_title' => string 'Pretium sed tempor' (length=18)
          public 'post_excerpt' => string '' (length=0)
          public 'post_status' => string 'publish' (length=7)
          public 'comment_status' => string 'closed' (length=6)
          public 'ping_status' => string 'closed' (length=6)
          public 'post_password' => string '' (length=0)
          public 'post_name' => string 'pretium-sed-tempor' (length=18)
          public 'to_ping' => string '' (length=0)
          public 'pinged' => string '' (length=0)
          public 'post_modified' => string '2018-11-30 16:40:46' (length=19)
          public 'post_modified_gmt' => string '2018-11-30 15:40:46' (length=19)
          public 'post_content_filtered' => string '' (length=0)
          public 'post_parent' => int 9
          public 'guid' => string 'http://exempel.se/vestibulum-ante-ipsum/etiam-pulvinar-felis/' (length=67)
          public 'menu_order' => int 0
          public 'post_type' => string 'page' (length=4)
          public 'post_mime_type' => string '' (length=0)
          public 'comment_count' => string '0' (length=1)
          public 'filter' => string 'raw' (length=3)
          public 'url' => string 'http://exempel.se/etiam-dictum-enim/pretium-sed-tempor/' (length=61)
      1 => 
        object(WP_Post)[6403]
          public 'ID' => int 27
          public 'post_author' => string '1' (length=1)
          public 'post_date' => string '2018-11-22 11:35:44' (length=19)
          public 'post_date_gmt' => string '2018-11-22 10:35:44' (length=19)
          public 'post_content' => string 'Aliquam eros elit, mollis a ipsum eu.' (length=37)
          public 'post_title' => string 'Mattis semper nibh' (length=18)
          public 'post_excerpt' => string '' (length=0)
          public 'post_status' => string 'publish' (length=7)
          public 'comment_status' => string 'closed' (length=6)
          public 'ping_status' => string 'closed' (length=6)
          public 'post_password' => string '' (length=0)
          public 'post_name' => string 'mattis-semper-nibh' (length=18)
          public 'to_ping' => string '' (length=0)
          public 'pinged' => string '' (length=0)
          public 'post_modified' => string '2018-11-30 16:43:52' (length=19)
          public 'post_modified_gmt' => string '2018-11-30 15:43:52' (length=19)
          public 'post_content_filtered' => string '' (length=0)
          public 'post_parent' => int 9
          public 'guid' => string 'http://exempel.se/vestibulum-ante-ipsum/duis-eu-odio/' (length=59)
          public 'menu_order' => int 0
          public 'post_type' => string 'page' (length=4)
          public 'post_mime_type' => string '' (length=0)
          public 'comment_count' => string '0' (length=1)
          public 'filter' => string 'raw' (length=3)
          public 'url' => string 'http://exempel.se/etiam-dictum-enim/mattis-semper-nibh/' (length=61)

版本历史

1.2.0

  • 调整了composer.json中的路径

1.1.0

  • 更新了关于许可模型的信息
  • 附上了许可模型文件

1.0.0

  • 第一个版本