vaersaagod/linkmate
Composer 安装命令:
composer require vaersaagod/linkmate
包简介
Let's hook you up, mate!
README 文档
README
Let's hook you up, mate!
This is a link field for Craft CMS, forked from Sebastian Lenz' fabolous Typed Link Field (v1). It's made for Værsågod & friends - no support is given whatsoever. You should probably use the original instead.
Requirements
This plugin requires Craft CMS 5.0.0 or later.
Installation
To install the plugin, follow these instructions.
-
Open your terminal and go to your Craft project:
cd /path/to/project -
Then tell Composer to load the plugin:
composer require vaersaagod/linkmate -
In the Control Panel, go to Settings → Plugins and click the “Install” button for LinkMate.
Templating
Link fields on your models will return an instance of vaersaagod\linkmate\models\Link. Rendering a link
field directly within a template will return the url the field is pointing to.
<a href="{{ item.myLinkField }}">Link</a>
You can use the following accessors to get the different properties of the link:
{{ item.myLinkField.getElement() }}
{{ item.myLinkField.getLinkAttributes() }}
{{ item.myLinkField.getTarget() }}
{{ item.myLinkField.getText() }}
{{ item.myLinkField.getUrl() }}
{{ item.myLinkField.hasElement() }}
{{ item.myLinkField.isEmpty() }}
{{ item.myLinkField.getCustomText() }}
Use the getLink utility function to render a full html link:
{{ item.myLinkField.getLink() }}
You can pass the desired content of the link as a string, e.g.
{{ entry.linkField.getLink('Imprint') }}
You may also pass an array of attributes. When doing this you can override
the default attributes href and target. The special attribute text
will be used as the link content.
{{ entry.linkField.getLink({
class: 'my-link-class',
target: '_blank',
text: 'Imprint',
}) }}
You can also compose your own markup quickly by simply consuming the link
attributes exposed by getLinkAttributes on the link model. This method accepts
an additional parameter allowing you to inject additional attributes as an
associative array.
<a {{ entry.linkField.getLinkAttributes() }}>
<span>Custom markup</span>
</a>
API
You can register additional link types by listening to the EVENT_REGISTER_LINK_TYPES
event of the plugin. If you just want to add another element type, you can do it like this in
your module:
use craft\commerce\elements\Product; use vaersaagod\linkmate\LinkMate as LinkPlugin; use vaersaagod\linkmate\events\LinkTypeEvent; use vaersaagod\linkmate\models\ElementLinkType; use yii\base\Event; /** * Custom module class. */ class Module extends \yii\base\Module { public function init() { parent::init(); Event::on( LinkPlugin::class, LinkPlugin::EVENT_REGISTER_LINK_TYPES, function(LinkTypeEvent $event) { $event->linkTypes['product'] = new ElementLinkType(Product::class); } ); } }
Each link type must have an unique name and a definition object implementing vaersaagod\linkmate\modles\LinkTypeInterface.
Take a look at the bundled link types ElementLinkType and InputLinkType to get an idea of how to write your own
link type definitions.
vaersaagod/linkmate 适用场景与选型建议
vaersaagod/linkmate 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.08k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 04 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「cms」 「link」 「Craft」 「craftcms」 「craft-plugin」 「linkmate」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 vaersaagod/linkmate 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vaersaagod/linkmate 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 vaersaagod/linkmate 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Expand, collapse, change the status of, or delete multiple blocks in a Matrix field simultaneously.
A couple of handy form fields and objects for managing external and internal links on DataObjects
PHP library that allows linking queries from diferent physical databases using mysql pdo database connections
Custom links on your sidebar for Laravel Nova.
GraphQL authentication for your headless Craft CMS applications.
Set Links with a specific language parameter
统计信息
- 总下载量: 2.08k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-04-28