定制 fof/links 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fof/links

Composer 安装命令:

composer require fof/links

包简介

Manage Flarum primary navbar menu links

关键字:

README 文档

README

License Latest Stable Version Total Downloads

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 我们能提供哪些服务?
定制开发 / 二次开发

基于 fof/links 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 130.97k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 41
  • 点击次数: 27
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 38
  • Watchers: 6
  • Forks: 13
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-01-06