regionhalland/region-halland-plugin-tree-first-level

返回侧边栏分类中第一级的前端插件

v1.7.0 2022-11-24 06:59 UTC

This package is auto-updated.

Last update: 2024-09-24 10:55:22 UTC


README

如何使用Region Hallands插件"RhTreeFirstLevel"

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

使用范围

此插件创建一个数组(),其中包含侧边栏分类中所有parent = 0的页面

许可模型

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

LICENSE (https://regionhalland.visualstudio.com/public.RhWpPlugIns/_git/RhTreeFirstLevel?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 clone https://regionhalland.visualstudio.com/public.RhWpPlugIns/_git/RhTreeFirstLevel

通过composer导入插件

注意!确保获取最新版本。

"require": {
  "regionhalland/region-halland-plugin-tree-first-level": "1.0.0"
},

通过"Blade"循环显示"页面"信息

@php($first_level_pages = get_region_halland_tree_first_level())	
    @if(isset($first_level_pages) && !empty($first_level_pages))
        @foreach($first_level_pages as $first_level_page)
            @if($first_level_page->is_active == 1)
                <a class="active" href="{{ $first_level_page->url }}">{{ $first_level_page->post_title }}</a>
            @else
                <a href="{{ $first_level_page->url }}">{{ $first_level_page->post_title }}</a>
            @endif
        @endforeach
    @endif
@endif

通过"Blade"循环显示最简单的"页面"信息

  • 注意!这不会创建任何点击会话
  • 也没有显示活动状态
@php($first_level_pages = get_region_halland_tree_first_level_simple())  
    @if(isset($first_level_pages) && !empty($first_level_pages))
        @foreach($first_level_pages as $first_level_page)
            <a href="{{ $first_level_page->url }}">{{ $first_level_page->post_title }}</a>
        @endforeach
    @endif
@endif

数组可能的外观示例

array (size=3)
  0 => 
    object(WP_Post)[8847]
      public 'ID' => int 7
      public 'post_author' => string '1' (length=1)
      public 'post_date' => string '2018-03-13 10:14:31' (length=19)
      public 'post_date_gmt' => string '2018-03-13 10:14:31' (length=19)
      public 'post_content' => string '' (length=0)
      public 'post_title' => string 'Lorem Ipsum' (length=16)
      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 'lorem-ipsum' (length=15)
      public 'to_ping' => string '' (length=0)
      public 'pinged' => string '' (length=0)
      public 'post_modified' => string '2018-11-06 15:14:31' (length=19)
      public 'post_modified_gmt' => string '2018-11-06 13:14:31' (length=19)
      public 'post_content_filtered' => string '' (length=0)
      public 'post_parent' => int 0
      public 'guid' => string 'http://exempel.se/?page_id=7' (length=25)
      public 'menu_order' => int 7
      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/lorem-ipsum/' (length=38)
      public 'is_active' => int 1
  1 => 
    object(WP_Post)[8849]
      public 'ID' => int 11
      public 'post_author' => string '1' (length=1)
      public 'post_date' => string '2018-03-13 10:15:01' (length=19)
      public 'post_date_gmt' => string '2018-03-13 10:15:01' (length=19)
      public 'post_content' => string '' (length=0)
      public 'post_title' => string 'Aldu integer' (length=19)
      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 'aldu-integer' (length=18)
      public 'to_ping' => string '' (length=0)
      public 'pinged' => string '' (length=0)
      public 'post_modified' => string '2018-11-01 15:48:03' (length=19)
      public 'post_modified_gmt' => string '2018-11-01 13:48:03' (length=19)
      public 'post_content_filtered' => string '' (length=0)
      public 'post_parent' => int 0
      public 'guid' => string 'http://exempel.se/?page_id=11' (length=26)
      public 'menu_order' => int 2
      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/aldu-integer/' (length=41)
      public 'is_active' => int 0
  2 => 
    object(WP_Post)[8851]
      public 'ID' => int 17
      public 'post_author' => string '2' (length=1)
      public 'post_date' => string '2018-03-13 10:15:37' (length=19)
      public 'post_date_gmt' => string '2018-03-13 10:15:37' (length=19)
      public 'post_content' => string '' (length=0)
      public 'post_title' => string 'Aliquam eros elit' (length=21)
      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 'aliquam-eros-elit' (length=21)
      public 'to_ping' => string '' (length=0)
      public 'pinged' => string '' (length=0)
      public 'post_modified' => string '2018-11-06 20:34:26' (length=19)
      public 'post_modified_gmt' => string '2018-11-06 18:34:26' (length=19)
      public 'post_content_filtered' => string '' (length=0)
      public 'post_parent' => int 0
      public 'guid' => string 'http://exempel.se/?page_id=17' (length=26)
      public 'menu_order' => int 3
      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/aliquam-eros-elit/' (length=44)
      public 'is_active' => int 0

版本历史

1.7.0

  • 如果存在,则使用短名称的功能

1.6.0

  • 添加了Packagist发布管道

1.5.0

  • 包含获取最简单信息的功能

1.4.0

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

1.3.0

  • 添加了字段is_active,返回1或0
  • 如果没有条目is_active = 1,则第一个条目is_active = 1
  • 存在向后兼容性,因为字段active = true仍然存在
  • 但是,在某些情况下,此字段可能返回没有active = true的条目

1.2.1

  • 检查是否已经设置了session_start

1.2.0

  • 如果post_parent = 0,则保存一个带有ID的会话
  • 然后使用ID来设置active

1.1.0

  • 可选排序,默认为"menu_order"

1.0.0

  • 第一个版本