定制 sourcebroker/singleview 二次开发

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

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

sourcebroker/singleview

Composer 安装命令:

composer require sourcebroker/singleview

包简介

Allows to display single view on different page than list view and still keep urls user and SEO friendly

README 文档

README

https://poser.pugx.org/sourcebroker/singleview/v/stable https://poser.pugx.org/sourcebroker/singleview/license

What does it do?

This extension allows to display single view on different page than list view and still keep urls user and SEO friendly.

Look at example below for better understanding.

Lets take following list view url:

https://www.example.com/list/

TYPO3 default is that when you put single view on different page then there is no easy way to remove it from slugified url. You will get something like below (single view is on separate page named "detail"):

https://www.example.com/list/detail/title-of-single-item/

If you will use ext:singleview then you can put single view on different page than list view but the slugified url will still look nice like below - so no /detail/ part.

https://www.example.com/list/title-of-single-item/

Installation

Use composer:

composer require sourcebroker/singleview

Usage

Each configuration of the ext:singleview settings has to be registered in your ext_localconf.php file using \SourceBroker\Singleview\Service\SingleViewService::registerConfig() static method as in example below (for ext:news)

<?php

\SourceBroker\Singleview\Service\SingleViewService::registerConfig(
    1,
    2,
    function() {
        $newsParams = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('tx_news_pi1');
        return !empty($newsParams['news']);
    },
    ['backend_layout'],
);

Parameters of registerConfig() method:

  1. First param is PID of the list view page.
  2. Second param is PID of the single view page.
  3. Third param is closure which returns boolean (or boolean value as a condition) which needs to be met to show single page on list view page. Closure is good here because at ext_localconf.php level the url/slug is not decoded yet so the value of \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('tx_news_pi1') is empty. But at the place the closure is executed the \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('tx_news_pi1') will return good value.
  4. Fourth param is optional and its array of strings with names of the fields which will be copied from single page to list page. If you use backend_layouts for managing your layouts then probably you should put there ['backend_layout']

IMPORTANT!

Single view links should point to the same page uid as list view.

Technical background

The idea behind is to use TYPO3 build in feature "Show content from pid" which you can find in page properties. In this extension value for "Show content from pid" field is set dynamically based on $_GET parameter. When TYPO3 renders page with list view then ext:singleview checks if $_GET parameter has single view request. If this is true then it sets "content_from_pid" field with value of single view page uid. This way single view page with its content and layout is shown on list view page.

To be sure that TYPO3 will not use one cache for list view and single view a "content_from_pid" is added to hashBase. You can deactivate this behaviour by setting: $GLOBALS['TYPO3_CONF_VARS']['EXT']['EXTCONF']['singleview']['hashBaseCustomization']['enabled'] = false;

Changelog

See https://github.com/sourcebroker/singleview/blob/master/CHANGELOG.rst

sourcebroker/singleview 适用场景与选型建议

sourcebroker/singleview 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12.35k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2018 年 02 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 12.35k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 17
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2018-02-10