如何通过分页使过滤器成为可能

问题描述 投票:0回答:1

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个回答
0
投票

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

TypoScript:

plugin.tx_yourext_plugin.features.requireCHashArgumentForActionArguments = 0

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

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

OR

ext_localconf.php

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

控制器:

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



FLUID / HTML:

解决方案1:拥有普通的HTML表单(不包含FLUID / ViewHelper):

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

解决方案2:拥有以下内容的ViewHelper-然后,他可以用作原件(他仅阻止产品自动生成__引荐来源网址的隐藏字段以及trustedproperties的隐藏字段):

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'}">



但是我还有一个问题-我没有过滤器形式的漂亮网址。因此,如果我发送表格的网址不是很好-但是如果我在此之后使用分页,则该网址很好并且很干净。

有人有主意吗?

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: [] }
© www.soinside.com 2019 - 2024. All rights reserved.