getolympus/olympus-dionysos-field-content

内容字段,此组件是Olympus Dionysos字段的一部分。

v0.0.12 2020-04-19 23:59 UTC

This package is auto-updated.

Last update: 2024-09-20 10:37:25 UTC


README

此组件是WordPress的 Olympus Dionysos字段 的一部分。

composer require getolympus/olympus-dionysos-field-content

Olympus Component CodeFactor Grade Packagist Version MIT

字段初始化

使用以下行在您的 WordPress 管理页面或自定义文章类型的元字段中添加 content field
注意 $identifier(第一个 ::build() 参数)被设置为 false,因为在数据库中没有存储值。

return \GetOlympus\Dionysos\Field\Content::build(false, [
    'title'   => 'The Dark Knight',
    'content' => '',
    'debug'   => false,
    'file'    => 'im_the_batman.php',
    'vars'    => [
        'question' => 'Who\'s the Batman?',
        'answers'  => [
            'the-joker'    => 'The Joker',
            'harley-quinn' => 'Harley Quinn',
            'bruce-wayne'  => 'Bruce Wayne, don\'t tell anybody!',
            'gotham-city'  => 'Gotham City',
        ],
    ],
]);

变量定义

注意

  • content 设置为显示HTML标签。如果文件不存在,它可以作为后备使用
  • debug 设置为 true 以在文件包含失败时启用调试模式
  • file 设置为定义要作为 include_once PHP函数包含的PHP文件路径

变量使用

在包含的文件(此例中的 im_the_batman.php),您可以使用 $v 变量作为数组

// Display question
echo '<h2>'.stripslashes($v['question']).'</h2>';
echo '<ul>';

// Display answers choices with radio button
foreach ($v['answers'] as $k => $answer) {
    echo '<li class="'.$k.' is-the-batman">'.stripslashes($answer).'</li>';
}

echo '</ul>';

内容显示优先级

组件将按优先级显示

  1. 包含的 file 路径
  2. content 中的所有内容

注意:不要忘记将 debug 设置为 true 以在 file 不存在或不可读的情况下显示错误。

发布历史

0.0.12

  • 删除无用描述

0.0.11

  • 新的Olympus组件兼容性
  • 更改仓库以成为Dionysos字段的一部分

0.0.10

  • 修复:在twig文件中显示内容原始数据

贡献

  1. 分叉它(https://github.com/GetOlympus/olympus-dionysos-field-content/fork
  2. 创建您的功能分支(git checkout -b feature/fooBar
  3. 提交您的更改(git commit -am 'Add some fooBar'
  4. 将分支推送到远程仓库(git push origin feature/fooBar
  5. 创建一个新的拉取请求

Achraf Chouk 使用♥构建 ~ 自从很久以前(c)。