【问题标题】:How to make a filter possible with pagination如何通过分页使过滤器成为可能
【发布时间】:2019-10-30 11:41:33
【问题描述】:

TYPO3 9 如何为 widget.paginate 设置过滤器? 示例:

<f:form name="filter" controller="myController" pluginName="Plugin" action="list" method="POST">
    <f:if condition="{types}">
        <f:for each="{types}" as="type">
            <f:form.checkbox name="filter[types][]" value="{type.uid}" />
        </f:for>
    </f:if>
    ...

<f:widget.paginate objects="{myObject}" as="Objects" configuration="{itemsPerPage: 20, insertAbove: 1, insertBelow: 1, maximumNumberOfLinks: 10, addQueryString: 1, addQueryStringMethod: 'POST'}">...

但这仅适用于第一页 - 第二页丢失了参数。

下一个问题:如何为分页设置 nextPageLink (ajax)? f:widget.link 不工作:https://forge.typo3.org/issues/89522 谢谢你:)

【问题讨论】:

    标签: php typo3 fluid extbase


    【解决方案1】:

    最后,我找到了2个解决方案:

    打字稿:

    plugin.tx_yourext_plugin.features.requireCHashArgumentForActionArguments = 0
    

    控制器:(通过方法参数或通过 $ this->request 轻松访问)

    public function listAction (int $ argument = 0) {...
    

    ext_localconf.php

    $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'][] = 'tx_yourext_plugin[argument]';
    

    控制器:

    public function listAction() {
        $argument = $this->request->getArgument('argument');
    



    流体/HTML:

    解决方案 1: 自己的普通 HTML 表单(没有 FLUID / ViewHelper):

    <form action = '<f:uri.action action = "cunning" controller = "job"/>' method = "GET">
    <select name = "tx_yourext_plugin [argument]">...
    

    解决方案 2: 拥有如下内容的 ViewHelper - 然后他可以用作原件(他只阻止生产自动生成 __referrer 隐藏字段以及受信任属性的隐藏字段):

    class FormViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper {
        protected function renderHiddenReferrerFields () {
            return ";
        }
    
        protected function renderTrustedPropertiesField () {
            return ";
        }
    }
    

    非常感谢https://www.ophidia.net/fluid-fform-referrer-deaktivieren/




    对于这两种解决方案: 流体分页: (注意:从 TYPO3 10 开始,addQueryStringMethod:'POST' 已被贬低)

    <f:widget.paginate... configuration = "{... addQueryString: 'true', addQueryStringMethod: 'GET'}">
    



    但是我还有一个问题——我没有得到过滤表单的漂亮网址。 因此,如果我发送表单,则 url 不是很好 - 但如果我在那之后使用分页,那么 url 很好而且干净。

    有人出主意吗?

    MyPlugin:
    type: Extbase
    extension: MyExtKeyNameSpace
    plugin: PluginName
    defaultController: 'Controller::list'
    routes:
      # - { routePath: '/{page-label}-{page}', _controller: 'Controller::list', _arguments: {'page': '@widget_0/currentPage'} }
      # - { routePath: '/{type-label}-{type}', _controller: 'Controller::list', _arguments: {'type': 'pluginTypes'} }
      # - { routePath: '/{area-label}-{area}', _controller: 'Controller::list', _arguments: {'area': 'pluginAreas'} }
      # - { routePath: '/type-{type}/area-{area}', _controller: 'Controller::list', _arguments: {'type': 'pluginTypes', 'area': 'pluginAreas'} }
      - { routePath: '/{page-label}{page}/{type-label}{type}/{area-label}{area}', _controller: 'Controller::list', _arguments: {'page': '@widget_0/currentPage', 'type': 'pluginTypes', 'area': 'pluginAreas'} }
      - { routePath: '/{company_slug}/{plugin_slug}', _controller: 'Controller::show', _arguments: {'company_slug': 'company', 'plugin_slug': 'plugin'} }
    defaults:
      page: ''
      type: ''
      area: ''
    requirements:
      page: '\d+'
      type: '\d+'
      area: '\d+'
    aspects:
      page: { type: StaticRangeMapper, start: '1', end: '100' }
      page-label: { type: LocaleModifier, default: 'page-', localeMap: [{ locale: 'en_.*', value: 'page-' }, { locale: 'de_.*', value: 'seite-' }] }
      company_slug: { type: 'PersistedAliasMapper', tableName: 'tt_address', routeFieldName: 'slug' }
      plugin_slug: { type: 'PersistedAliasMapper', tableName: 'tx_myextkey_domain_model_plugin', routeFieldName: 'slug' }
      type-label: { type: LocaleModifier, default: 'type-', localeMap: [] }
      area-label: { type: LocaleModifier, default: 'area-', localeMap: [] }
    

    【讨论】:

      猜你喜欢
      • 2011-09-13
      • 2015-02-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多