phile / content-variables
一个插件,用于在内容解析前添加自定义变量。
1.0.1
2018-03-07 16:02 UTC
Requires
- phile-cms/phile: ^1.9
- phile-cms/plugin-installer-plugin: ^1.0
This package is auto-updated.
Last update: 2024-08-29 03:20:53 UTC
README
一个为 Phile 添加自定义变量的插件,在内容解析前使用。
1.1 安装(composer)
composer require phile/content-variables
1.2 安装(下载)
- 安装最新版本的 Phile
- 将此仓库克隆到
plugins/phile/contentVariables
2. 激活
安装插件后,您需要将以下行添加到您的 config.php
文件中
$config['plugins']['phile\\contentVariables'] = array('active' => true);
使用方法
您 必须 在您的配置中有一个 variables
数组。
$config['variables'] = array( 'site_title' => $config['site_title'], 'base_url' => 'https://example.com/ );
这些键是变量,值是替换的字符串。因此,现在当您在 markdown/textile/content 页面中引用 %base_url%
时,它将被渲染为您的实际基础 URL
This is a link to my [base URL](%base_url%)
将被渲染为
<p>This is a link to my <a href="https://example.com">base URL</a></p>
一个名为 PhileCMS 的网站的另一个示例
Welcome to %site_title%!
变为
<p>Welcome to PhileCMS!</p>
配置
此插件允许您设置变量的开放和闭合标签。默认情况下,它们都设置为以下内容
'open_tag' => '%', // the open tag for the variable 'close_tag' => '%' // the close tag for the variable
这意味着任何用 %
符号包裹的文本都将被替换。