定制 flowpack/listable 二次开发

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

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

flowpack/listable

Composer 安装命令:

composer require flowpack/listable

包简介

Tiny extension for listing things

README 文档

README

This Neos package solves one problem: help you list any nodes in Fusion. The idea is very simple: you often need to display list of things (e.g. news, articles etc), and the concern of listing items should better be separated from the concern of rendering items. This package provides a solid foundation for listing, while allowing you to take care of rendering stuff on your own.

TL;DR

  1. Install the package with composer: composer require flowpack/listable Here it is on packagist.
  2. If you want a paginated list, use Flowpack.Listable:PaginatedCollection.
  3. If you just want a simple list, use Flowpack.Listable:Collection (or just Neos.Fusion:Collection!).
  4. If you need a list with a header and an archive link, wrap you list into Flowpack.Listable:List
  5. For each of your nodetypes create a new Fusion object of type NodeTypeName + '.Short', or manually define a rendering object.
  6. Rely on public API keys when overriding settings.

Fusion objects

Keys documented here are considered public API and would be treated with semantic versioning in mind. Extend all other properties at your own risk.

Flowpack.Listable:Collection

This object is just a simple convienince wrapper around Neos.Fusion:Collection, use it if you want to save a few keystrokes. It wraps the list with UL and LI tags with a provided name and also set Flowpack.Listable:ContentCaseShort as a default for itemRenderer.

Configuration options:

Setting Description Defaults
items An instance of ElasticSearchQueryBuilder, FlowQuery object or an array of nodes 'to-be-set'
listClass Classname of UL tag ''
itemClass Classname of LI tag wrapping each item ''
itemRenderer Object used for rendering child items. Within it you get two context vars set: node and iterator 'Flowpack.Listable:ContentCaseShort'
itemName Name of the the node context variable 'node'
iterationName Name of the the iterator context variable 'iteration'

Example:

prototype(My.Custom:Object) < prototype(Flowpack.Listable:Collection) {
  items = ${q(site).find('[instanceof Something.Custom:Here]').sort('date', 'DESC').slice(0, 6).get()}
  listClass = 'MyList'
  itemClass = 'MyList-item'
}

It would use the object Something.Custom:Here.Short for rendering each item.

Make sure to correctly configure the cache.

Flowpack.Listable:PaginatedCollection

This object allows you to paginate either ElasticSearch results, FlowQuery result objects or pure Node arrays.

Configuration options:

Setting Description Defaults
collection An instance of ElasticSearchQueryBuilder, FlowQuery object or an array of nodes 'to-be-set'
itemsPerPage Number of items per page when using pagination 24
maximumNumberOfLinks Number of page links in pagination 15
listRenderer Object used for rendering the list. 'Flowpack.Listable:Collection'
showPreviousNextLinks Boolean value used to decide whether the previous and next links should be added false

When used with ElasticSearch, build the query, but don't execute it, the object will do it for you:

prototype(My.Custom:Object) < prototype(Flowpack.Listable:PaginatedCollection) {
  collection = ${Search.query(site).nodeType('Something.Custom:Here').sortDesc('date')}
  itemsPerPage = 12
  prototype(Flowpack.Listable:Collection) {
    listClass = 'MyPaginatedList'
    itemClass = 'MyPaginatedList-item'
  }
}

If you have additional URL parameters (e.g for a date filter) you have to register the argument and change the cache entryDiscriminator in order work accordingly. HINT: Do not forget to register a corresponding route for your custom argument.

prototype(My.Custom:Object) < prototype(Flowpack.Listable:PaginatedCollection) {
  ...

  prototype(Flowpack.Listable:PaginationParameters) {
    date = ${request.arguments.data}
  }

  @cache {
    entryDiscriminator = ${request.arguments.currentPage + request.arguments.date}
  }

}

This object is configured by default to dynamic cache mode for pagination to work. All you have to do is add correct entryTags and you are all set.

Flowpack.Listable:List

There's often a need to render a list with a header and an archive link. This object takes your list and wraps it with just that.

Configuration options:

Setting Description Defaults
wrapClass Class of the div that wraps the whole object ''
listTitle Title of the list ''
listTitleClass Class of the list title ''
archiveLink Nodepath for the archive link ''
archiveLinkTitle Title of the archive link ''
archiveLinkClass Classname of the archive link ''
archiveLinkAdditionalParams AdditionalParams of the archive link, e.g. @context.archiveLinkAdditionalParams = ${{archive: 1}} {}
list A list that this object should wrap value

Example:

prototype(My.Custom:Object) < prototype(Flowpack.Listable:PaginatedCollection) {
  @process.list = Flowpack.Listable:List {
    listTitle = 'My List'
    archiveLink = '~/page-path-or-identifier'
    archiveLinkTitle = 'See all news'
  }
  collection = ${q(site).find('[instanceof Something.Custom:Here]').sort('date', 'DESC').slice(0, 6).get()}
}

Flowpack.Listable:Pagination

You can also use pagination standalone from the PaginatedCollection.

Configuration options:

Setting Description Defaults
totalCount A total count of items 'to-be-set'
itemsPerPage Number of items per page 24
maximumNumberOfLinks A maximum number of links 15
class A class around pagination 'Pagination'
itemClass A total count of items 'Pagination-item'
currentItemClass A class for a current item 'isCurrent'
currentPage Current page, starting with 1 `${request.arguments.currentPage
showPreviousNextLinks Boolean value used to decide whether the previous and next links should be added false

FlowQuery Helpers you can use

filterByDate

Filter nodes by properties of type date.

sortRecursiveByIndex

Sort nodes by their position in the node tree. Please use with care, as this can become a very expensive operation, if you operate on bigger subtrees.

Example:

${q(node).children("main").sortRecursiveByIndex('DESC').get()}

flowpack/listable 适用场景与选型建议

flowpack/listable 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 221.49k 次下载、GitHub Stars 达 35, 最近一次更新时间为 2015 年 12 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 221.49k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 35
  • 点击次数: 18
  • 依赖项目数: 8
  • 推荐数: 0

GitHub 信息

  • Stars: 35
  • Watchers: 4
  • Forks: 18
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-12-09