fof/links
Composer 安装命令:
composer require fof/links
包简介
Manage Flarum primary navbar menu links
关键字:
README 文档
README
A Flarum extension that allows you to add links to your forum's navigation.
Features
- Add links to your forum's navigation menu
- Support for both internal and external links
- Control link visibility based on user groups
- Guest-only links
- Hierarchical links (dropdown menus)
- Programmatic link definition via PHP
Installation
Install with composer:
composer require fof/links
Updating
composer update fof/links php flarum cache:clear
Usage
Admin Interface
Links can be managed through the admin interface under the "Links" tab.
Programmatic Link Definition
This extension provides a way to define links programmatically through PHP code. This can be useful in situations where there are multiple environments (ie dev, staging, production) and you want to define a set of links only once (in code), and not have to re-enter or define them via the admin interface.
Basic Usage
use FoF\Links\Extend\LinksOverride; use FoF\Links\LinkDefinition; return [ // Other extenders... (new LinksOverride()) ->addLinks([ LinkDefinition::make() ->withId(1) ->withTranslationKey('my-extension.link') ->withUrl('/my-page') ->withIcon('fas fa-link') ->withIsInternal(true) ]) ];
Hierarchical Links
You can create dropdown menus by adding child links:
use FoF\Links\Extend\LinksOverride; use FoF\Links\LinkDefinition; $parent = LinkDefinition::make() ->withId(1) ->withTranslationKey('my-extension.parent') ->withUrl('/parent'); $child1 = LinkDefinition::make() ->withId(2) ->withTranslationKey('my-extension.child1') ->withUrl('/child1'); $child2 = LinkDefinition::make() ->withId(3) ->withTranslationKey('my-extension.child2') ->withUrl('/child2'); $parent->addChild($child1); $parent->addChild($child2); return [ // Other extenders... (new LinksOverride()) ->addLinks([$parent]) ];
Using a Provider Class
For more complex scenarios, you can use a provider class:
use FoF\Links\Extend\LinksOverride; use FoF\Links\LinkDefinition; class MyLinksProvider { public function __invoke() { return [ LinkDefinition::make() ->withId(1) ->withTranslationKey('my-extension.link') ->withUrl('/my-page') ]; } } return [ // Other extenders... (new LinksOverride()) ->addLinks(MyLinksProvider::class) ];
LinkDefinition API
The LinkDefinition class provides a fluent interface for defining links:
| Method | Description |
|---|---|
withId(int $id) |
Set the link ID |
withTranslationKey(string $key) |
Set the translation key for the link title |
withUrl(string $url) |
Set the link URL |
withIcon(string $icon) |
Set the link icon (FontAwesome class) |
withIsInternal(bool $isInternal) |
Set whether the link is internal |
withIsNewtab(bool $isNewtab) |
Set whether the link should open in a new tab |
withUseRelme(bool $useRelme) |
Set whether to use rel="me" attribute |
withGuestOnly(bool $guestOnly) |
Set whether the link is only visible to guests |
withParentId(?int $parentId) |
Set the parent link ID |
withPosition(int $position) |
Set the link position |
addChild(LinkDefinition $child) |
Add a child link |
Links
An extension by FriendsOfFlarum.
fof/links 适用场景与选型建议
fof/links 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 130.97k 次下载、GitHub Stars 达 38, 最近一次更新时间为 2019 年 01 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「flarum」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 fof/links 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fof/links 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 fof/links 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Adds more BBCode
Output of discussions lists in form of cards
Allow users to log in with QQ
A headless CLI performance benchmarking tool for Flarum
The admin panel of afrux/asirem
Enhanced typography for french writings, mainly around punctuation.
统计信息
- 总下载量: 130.97k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 41
- 点击次数: 27
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-01-06