goldfinch / shortcode
在Silverstripe中创建自定义短语的快捷方式
v2.0.6
2024-05-16 03:01 UTC
Requires
- php: >=8.0
- goldfinch/helpers: ^2.0
- silverstripe/admin: ^2.0
- silverstripe/framework: ^5.0
README
在Silverstripe中创建自定义短语的快捷方式。
安装
composer require goldfinch/shortcode
可用的Taz命令
如果您之前没有使用过Taz🌪️,则必须在您的根项目文件夹中提供一个taz文件,命令为cp vendor/goldfinch/taz/taz taz
创建新短码
php taz make:shortcode
用例示例
让我们创建一些短码,一个用于显示<hr>
标签的单个hr
,以及一个可以关闭的st
,它会将文本<strong>text</strong>
包裹起来并使其加粗
1. 创建短码
php taz make:shortcode hr php taz make:shortcode st
2. 编辑模板
Taz为我们注册了短码并创建了模板hr.ss
和st.ss
,存储在our_theme/templates/Shortcodes/
中。我们可以根据需要更新它们。
3. 设置数据库类型
假设我们希望在DataObject
中的Title
支持短码,我们需要使用SCVarchar
而不是Varchar
private static $db = [ 'Title' => 'SCVarchar', ];
完成,现在我们可以在模板中检查$Title
的输出以查看结果。
许可证
MIT许可证(MIT)