brettdewoody/statamic-global-variable-editor

语言: PHP

git: https://github.com/brettdewoody/statamic-global-variable-editor

Statamic CMS的附加组件,允许编辑主题的全局变量
An add-on for the Statamic CMS to allow editing of a theme's global variables
README.md (中文)

Statamic Add-on - 全局变量编辑器

作者:Brett DeWoody(2015)2.0.0版

Statamic CMS的附加组件,用于通过控制面板编辑全局变量。用于编辑网站上使用的常用文本片段。

安装和设置

  1. 下载并解压缩附加组件。
  2. 将加载项/地球仪拖到您网站的插件文件夹中。
  3. 打开_config / settings.yaml文件并添加globes:true到_admin_nav设置。这将在控制面板中创建一个选项卡,以快速编辑全局变量。
  4. 打开_themes / [theme-name] /theme.yaml文件并定义要编辑的全局变量。

要使变量可编辑,首先要创建第一级全局变量,然后将变量嵌套在globals var下。

例如,如果您想拥有一个可编辑的电话号码全局变量,那么您可以这样做。

    globals:
      -
        name: phone
        display: Phone
        value: 555-555-5555

如果你想添加另一个全局变量,比如说一个电子邮件地址,你的全局变量将如下所示:

    globals:
      -
        name: phone
        display: Phone
        value: 555-555-5555
      -
        name: email
        display: Email
        value: you@yourdomain.com
  1. 使用{{globes}}标记在模板中显示全局变量。在我们之前的示例中,如果我们要显示电话号码,我们会将{{globes name ='phone'}}添加到我们的模板或布局中。

域类型

全局变量可以在Statamic中使用一组有限的内置字段。使用type参数定义fieldtype。如果未设置任何类型,则全局变量将默认为文本类型。

    globals:
      -
        name: phone
        display: Phone
        type: redactor
        value: 555-555-5555

允许的类型是:

  • 复选框
  • 复选框
  • 日期
  • markitup
  • 无线电
  • redactor - 没有文件上传
  • 选择
  • 标签
  • 文本
  • textarea的
  • 时间
  • 用户

用法

您的管理面板中会有一个标签为常量的新标签。单击选项卡将显示可编辑的全局变量,并为您提供编辑它们的选项。

要更改值,只需输入更新的值,然后单击底部的“保存并发布”按钮。

啤酒我

如果您发现附加组件有用并在项目中使用它,请考虑给我买啤酒。没有压力,但你会让我高兴并帮助保持Globes最新。

谢谢,我希望你喜欢Globes,它会让你的生活更美好。好多了。

更新日志

V2

  • 增加了fieldtypepes

V1

  • 初始发行

本文使用googletrans自动翻译,仅供参考, 原文来自github.com

en_README.md

Statamic Add-on - Global Variable Editor

By Brett DeWoody (2015) Version 2.0.0

An add-on for the Statamic CMS to edit global variables through the control panel. Useful for editing common snippets of text used on the site.

Installation & Setup

  1. Download and unzip the add-on.

  2. Drag _add-ons/globes into your site's _add-ons folder.

  3. Open _config/settings.yaml file and add globes:true to the _admin_nav setting. This will create a tab in the control panel to quickly edit your global variables.

  4. Open _themes/[theme-name]/theme.yaml file and define the global variables you want to be editable.

To make a variable editable, first create a first-level var of globals, then nest your variables under the globals var.

For example, if you wanted to have an editable phone number global variable you would do this.

    globals:
      -
        name: phone
        display: Phone
        value: 555-555-5555

If you wanted to add another global variable, say an email address, your globals variable would look like so:

    globals:
      -
        name: phone
        display: Phone
        value: 555-555-5555
      -
        name: email
        display: Email
        value: you@yourdomain.com
  1. Display the global variables in your template using the {{ globes }} tag. In our example from before, if we wanted to display the phone number we would add {{ globes name='phone' }} to our templates or layouts.

Fieldtypes

Global variables can use a limited set of the built-in fieldtypes in Statamic. Define the fieldtype using the type parameter. If no type is set the global variable will default to a text type.

    globals:
      -
        name: phone
        display: Phone
        type: redactor
        value: 555-555-5555

The allowed types are:

  • checkbox
  • checkboxes
  • date
  • markitup
  • radio
  • redactor - no file uploads however
  • select
  • tags
  • table
  • text
  • textarea
  • time
  • users

Usage

You'll have a new tab in your admin panel labeled Constants. Clicking the tab will display your editable global variables and give you the option to edit them.

To change a value, simply enter the updated value then click the Save & Publish button at the bottom.

Beer Me

If you find the add-on useful and use it on projects consider buying me a beer. No pressure, but you'll make me happy and help keep Globes up-to-date.

Thanks, and I hope you enjoy Globes and it makes your life better. Much, much better.

Changelog

v2

  • Addition of fieldtypes

v1

  • Initial Release