regionhalland / region-halland-plugin-current-category-and-child-categories
前端插件,返回当前分类 + 所有子分类 + 可以插入页面之间的内容
v1.1.0
2021-04-30 11:48 UTC
This package is auto-updated.
Last update: 2024-09-29 05:55:41 UTC
README
如何使用Region Halland的插件"RhCurrentCategoryAndChildCategories"
以下是使用插件"RhCurrentCategoryAndChildCategories"的说明。
使用范围
此插件创建一个数组(),包含当前分类 + 所有子分类 + 可以插入页面之间的内容
许可模型
此插件使用许可模型GPL-3.0。您可以通过随附的文件了解更多关于此许可模型的信息
LICENSE (https://regionhalland.visualstudio.com/public.RhWpPlugIns/_git/RhCurrentCategoryAndChildCategories?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/RhCurrentCategoryAndChildCategories
通过composer导入插件
以下两个部分需要您将其添加到composer文件中
仓库 = 插件存储的位置,在本例中是github
"repositories": [
{
"type": "vcs",
"url": "https://regionhalland.visualstudio.com/public.RhWpPlugIns/_git/RhCurrentCategoryAndChildCategories"
},
],
需求 = 指定您想要使用的插件版本,在本例中为1.0.0
注意!请确保您获取的是最新版本。
"require": {
"regionhalland/region-halland-plugin-current-category-and-child-categories": "1.0.0"
},
通过"Blade"循环页面
@php($myCategories = get_region_halland_current_category_and_child_categories())
@if(isset($myCategories))
<div>
<p>
{{ $myCategories['current_category']['term_name'] }}
</p>
</div>
@if (!empty($myCategories['category_children']))
<div>
@foreach ($myCategories['category_children'] as $myChilds)
<p class="rh-navigation-left__item-text">
@if ($myChilds['term_type'] == 1)
<a href="{{ $myChilds['term_url'] }}">
<span> {{ $myChilds['term_name'] }}</span>
</a>
@else
<a class="rh-link--navigation rh-navigation-left__item-link" href="{{ $myChilds['term_url'] }}">
<span>{{ $myChilds['term_name'] }}</span>
</a>
@endif
</p>
@endforeach
</div>
@endif
</div>
@endif
数组可能的样子示例
array (size=2)
'current_category' =>
array (size=1)
'term_name' => string 'Kategori 1' (length=10)
'category_children' =>
array (size=6)
0 =>
array (size=4)
'term_id' => string '68' (length=2)
'term_name' => string 'Sida A' (length=6)
'term_url' => string 'http://dev-intra.local/sida-a/' (length=30)
'term_type' => int 1
1 =>
array (size=4)
'term_id' => string '9' (length=1)
'term_name' => string 'Kategori 1.1' (length=12)
'term_url' => string 'http://dev-intra.local/category/kategori-1/kategori-1-1/' (length=56)
'term_type' => int 0
2 =>
array (size=4)
'term_id' => string '10' (length=2)
'term_name' => string 'Kategori 1.2' (length=12)
'term_url' => string 'http://dev-intra.local/category/kategori-1/kategori-1-2/' (length=56)
'term_type' => int 0
3 =>
array (size=4)
'term_id' => string '11' (length=2)
'term_name' => string 'Kategori 1.3' (length=12)
'term_url' => string 'http://dev-intra.local/category/kategori-1/kategori-1-3/' (length=56)
'term_type' => int 0
4 =>
array (size=4)
'term_id' => string '12' (length=2)
'term_name' => string 'Kategori 1.4' (length=12)
'term_url' => string 'http://dev-intra.local/category/kategori-1/kategori-1-4/' (length=56)
'term_type' => int 0
5 =>
array (size=4)
'term_id' => string '13' (length=2)
'term_name' => string 'Kategori 1.5' (length=12)
'term_url' => string 'http://dev-intra.local/category/kategori-1/kategori-1-5/' (length=56)
'term_type' => int 0
版本历史
1.1.0
- 修正了一个错误的if语句
1.0.0
- 第一个版本