visionbites / usage-reference
显示在对象蓝图上对页面或文件的引用。
1.2.3
2024-07-15 07:03 UTC
Requires
README
信息部分,用于显示页面或图像的所有引用列表。
安装
下载 Zip 文件
将插件文件夹复制到 site/plugins
Git 子模块
git submodule add https://github.com/visionbites/kirby-usage-reference.git site/plugins/usage-reference
Composer
composer require visionbites/usage-reference
使用方法
将 usageReference
部分添加到您的蓝图以显示当前页面的引用。添加一个 template
键来定义您正在寻找的页面类型。
示例
基本设置
sections: references: headline: References to this page type: usageReference template: template-name
文件设置
sections: file_data: type: fields fields: title: type: text label: Title alt: type: text label: Alternative title caption: type: textarea label: Image caption references: headline: References to this file type: usageReference
选项
目前只有两个选项
在 config.php
中设置选项
return [ 'visionbites.usage-reference' => [ 'expire' => 15 // in minutes 'cache' => true ], ];
请注意,如果添加了另一个引用,这可能会导致编辑器显示过时的数据。
在插件、模型和其他位置的使用
您可以使用在其他位置提供 ReferenceService
来访问在面板中显示的数据。
例如,如果您有一个与地方相关联的事件,但不是该地方的子事件,您可以在 PlacePage
模型中有一个 events()
方法
public function events() { $refService = new ReferenceService(); // pass the uuid of the place and the template that you are looking for $events = $refService->findReferencesForUuid($this->uuid()->toString(), 'event'); // depending on what you want to do with the events you can either return them here or // resolve the pages and return a pages collection $eventsPages = new Pages(); foreach ($events as $event) { $eventPage = $this->kirby()->page($event['uuid']); $eventsPages->append($eventPage); } return $eventsPages; }
待办事项
- 在引用页面更新时清除页面的缓存
- 使其能够识别文本链接
许可证
不建议在任何推广种族主义、性别歧视、恐同、动物虐待、暴力或其他任何形式仇恨言论的项目中使用此插件。