定制 mediadreams/md_newsfrontend 二次开发

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

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

mediadreams/md_newsfrontend

Composer 安装命令:

composer require mediadreams/md_newsfrontend

包简介

This TYPO3 extension enables frontend users to created news records.

README 文档

README

This extension enables a frontend user to add ext:news-records. Beside adding content for the normal text fields like title, teaser, bodytext it is also possible to upload an image and a file download as well as selecting a category.

Templates are ready to use with the bootstrap framework and icons will be shown, if you have Font Awesome icon set included in your project. Validation of input is done in the frontend, rich text editing enabled for the textarea and a date picker in place for the archive date.

Requirements

  • TYPO3 ^13.4 || ^14.0
  • ext:news ^11.0 || ^12.0 || ^13.0 || ^14.0

Installation

  • Install the extension via Composer or the Extension Manager
  • Add the Site Set "News Frontend" (mediadreams/md-newsfrontend) to your site configuration (config/sites/<yoursite>/config.yaml)
  • Configure the extension settings directly in the site configuration GUI or via settings.yaml

Important: If a TypoScript template record exists on your root page, make sure the checkboxes "Clear constants" and "Clear setup" are unchecked. When checked, they wipe all TypoScript loaded by Site Sets before the template record is processed, which results in empty extension settings.

Legacy TypoScript include

If you prefer the classic approach, you can still include the TypoScript manually from EXT:md_newsfrontend/Configuration/TypoScript/ and override constants as needed.

Usage

  • Add the pluign News frontend on a page, which is restricted by the frontend user login
  • Select a storage page in the plugin-tab in the field Record Storage Page
  • Now a frontend user is able to add, edit and delete own records

PSR-14 Events

Following PSR-14 events are available:

  • Mediadreams\MdNewsfrontend\Event\CreateActionBeforeSaveEvent: Called just before saving a new record
  • Mediadreams\MdNewsfrontend\Event\CreateActionAfterPersistEvent: Called after a new record was saved (new record Id is available)
  • Mediadreams\MdNewsfrontend\Event\UpdateActionBeforeSaveEvent: Called just before an existing record will be updated
  • Mediadreams\MdNewsfrontend\Event\DeleteActionBeforeDeleteEvent: Called just before a record will be deleted
  • Mediadreams\MdNewsfrontend\Event\ModifyAllowedMimeTypesEvent: Called during file upload validation to modify the allowed MIME types for a given file extension

Register an event

Add following lines in Configuration/Services.yaml of your own extension:

services:
  Vendor\Extension\EventListener\MyListener:
    tags:
      - name: event.listener
        identifier: 'ext-mdnewsfrontend/createActionBeforeSaveEvent'
        method: 'enrichNews'
        event: Mediadreams\MdNewsfrontend\Event\CreateActionBeforeSaveEvent

Add the class Vendor\Extension\EventListener\MyListener with the method enrichNews in your extension:

namespace Vendor\Extension\EventListener;

use Mediadreams\MdNewsfrontend\Event\CreateActionBeforeSaveEvent;

final class MyListener
{
    public function enrichNews(CreateActionBeforeSaveEvent $obj)
    {
        // Get news object
        $news = $obj->getNews();
        $news->setTeaser('Set some teaser...');

        // Get NewsController
        $newsController = $obj->getNewsController();
    }
}

ModifyAllowedMimeTypesEvent

The ModifyAllowedMimeTypesEvent is dispatched during file upload validation and allows you to extend or override the built-in MIME type map. This is useful when you need to permit file extensions that are not covered by the default configuration (e.g. svg, heic, odt).

The event provides the following methods:

  • getExtension(): string — the file extension being validated (lowercase, e.g. 'svg')
  • getMimeTypes(): array — the current list of allowed MIME types for this extension
  • setMimeTypes(array $mimeTypes): void — replace the entire list of allowed MIME types
  • addMimeType(string $mimeType): void — append a single MIME type to the existing list

Example: Allow SVG uploads by adding a listener in Configuration/Services.yaml:

services:
  Vendor\Extension\EventListener\AddSvgMimeType:
    tags:
      - name: event.listener
        identifier: 'my-extension/add-svg-mime-type'
        event: Mediadreams\MdNewsfrontend\Event\ModifyAllowedMimeTypesEvent
namespace Vendor\Extension\EventListener;

use Mediadreams\MdNewsfrontend\Event\ModifyAllowedMimeTypesEvent;

final class AddSvgMimeType
{
    public function __invoke(ModifyAllowedMimeTypesEvent $event): void
    {
        if ($event->getExtension() === 'svg') {
            $event->setMimeTypes(['image/svg+xml']);
        }
    }
}

Note: Extensions not present in the MIME type map skip the MIME check entirely. To enforce MIME validation for a new extension, add it via this event. To disable MIME validation for an existing extension, call $event->setMimeTypes([]) for that extension.

Bugs and Known Issues

If you find a bug, it would be nice if you add an issue on Github.

THANKS

Thanks a lot to all who make this outstanding TYPO3 project possible!

Credits

  • Extension icon was copied from ext:news and enriched with a pen from Font Awesome.
  • Thanks to Parsley.js, which I use for validating the form in the frontend.
  • Thanks to tiny, which I use as rich text editor in the frontend.
  • Thanks to flatpickr, which I use as date picker in the frontend.
  • And last but not least thanks to the guys at jQuery.

mediadreams/md_newsfrontend 适用场景与选型建议

mediadreams/md_newsfrontend 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 8.68k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2019 年 04 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「extension」 「news」 「frontend」 「typo3」 「fe_users」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 mediadreams/md_newsfrontend 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mediadreams/md_newsfrontend 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 3
  • Forks: 6
  • 开发语言: JavaScript

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2019-04-15