承接 art-and-flywork/kirby.plugin.fieldset 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

art-and-flywork/kirby.plugin.fieldset

Composer 安装命令:

composer require art-and-flywork/kirby.plugin.fieldset

包简介

Panel field which loads a fieldset and stores the values in a single field as yaml

README 文档

README

Panel field which loads a fieldset and stores the values in a single field as yaml.

This works like an extend with the difference that all all values from the fieldset fields are store in a single field. This way you van reuse the fieldset and bind it to a snippet: snippet('mySnippet', $page->the_fieldset()->yaml())

Usage

Create a blueprint with a fieldset:

site/blueprints/fieldsets/somefields.yml

type: group
fields:
  title:
    type: text
    label: A nice title
  text:
    type: textarea
    label: Type your text here

the type: group is not mandatory for this plugin to work, but it will make it work as a standard kirby field extend too when needed.

In your page yml add the fieldset field and point it to the fieldset blueprint:

site/blueprints/pages/default.yml

fields:
  myfields:
    type: fieldset
    blueprint: fieldsets/somefields
    label: Show me my fields

In the panel the fields from somefields.yml are loaded in the fieldset field:

alt text

The data is stored as yml in the txt file:

----

Myfields:

title: This is my title
text: This is my text

Using the values in templates

There are 2 ways to easily access the values stored in the fieldset field. There is a supplied chainable method or it's yaml can be decoded with the native yaml method or even passed

1. Using the supplied fieldmethod

The plugin introduces a field method to make the values accessible as regular chainable kirby fields:

<h1><?= $page->myfields()->fieldset()->title() ?></h1>
<?= $page->myfields()->fieldset()->text()->kirbytext() ?>

2. Yaml decode by hand

In the template the data is accessible as array by yaml decoding it:

default.php

<?php foreach ($page->myfields()->yaml() as $key => $value): ?>
  <p><?= $key ?> – <?= $value ?></p>  
<?php endforeach ?>

Once decoded the values can be directly passed to a snippet:

<?php snippet('mySnippet', $page->myfields()->yaml()) ?>

site/snippets/mySnippet.php

<h2><?= $title ?></h2>
<?= kirbytext($text) ?>

License

[MIT

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-09-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固