Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typo3 类型3,新闻:通过get参数更改排序顺序和方向_Typo3_Typo3 8.x_Tx News - Fatal编程技术网

Typo3 类型3,新闻:通过get参数更改排序顺序和方向

Typo3 类型3,新闻:通过get参数更改排序顺序和方向,typo3,typo3-8.x,tx-news,Typo3,Typo3 8.x,Tx News,在扩展新闻的列表视图中,我们需要更改排序顺序和排序方向的链接。是否有可能通过get参数更改这两个参数? 我取消选中了“禁用覆盖需求”选项,并尝试了一些组合,如 ?tx_news_pi1[orderDirection]=asc ?tx_news_pi1[settings][orderDirection]=asc 但这不起作用 谢谢 不妨试试: tx_news_pi1[覆盖需求][订单方向]=asc (虽然我不确定orderDirection是否正确,但可以查看手册/代码)据我所知,流体模板中没有

在扩展新闻的列表视图中,我们需要更改排序顺序和排序方向的链接。是否有可能通过get参数更改这两个参数? 我取消选中了“禁用覆盖需求”选项,并尝试了一些组合,如

?tx_news_pi1[orderDirection]=asc
?tx_news_pi1[settings][orderDirection]=asc
但这不起作用

谢谢

不妨试试:

tx_news_pi1[覆盖需求][订单方向]=asc


(虽然我不确定orderDirection是否正确,但可以查看手册/代码)

据我所知,流体模板中没有包含排序的直观选项,因为所有排序都是在打字脚本和FlexForm的级别上完成的

尽管如此,有不同的选项可以从前端启用排序:

  • 在TypoScript中,您可以根据当前的URL参数设置排序参数,最简单的方法是根据条件进行求解,您还可以自由定义自己的参数,而无需坚持使用新闻API。
    在任何情况下,您都应该使用始终附加并正确计算鸿沟的viewHelper创建用于排序的URL

    打字稿:

    #######
    ## Here you transfer the URL-parameters for sorting to the TypoScript-settings
    ## and also assure that only predefined values are accepted
    #######
    [globalVar = _GET|tx_news_pi1|orderBy = title]
        plugin.tx_news.settings.orderBy = title
    [globalVar = _GET|tx_news_pi1|orderBy = datetime]
        plugin.tx_news.settings.orderBy = datetime
    [globalVar = _GET|tx_news_pi1|orderBy = tstamp]
        plugin.tx_news.settings.orderBy = tstamp
    [globalVar = _GET|tx_news_pi1|orderBy = crdate]
        plugin.tx_news.settings.orderBy = crdate
    [global]
    
    [globalVar = _GET|tx_news_pi1|sort = desc]
        plugin.tx_news.settings.orderDirection = desc
    [else]
        plugin.tx_news.settings.orderDirection = asc
    [global]
    
    <f:link.action action="list" addQueryString="&tx_news_pi1[orderBy]=title&tx_news_pi1[sort]=asc">Sort by title: asc</f:link.action>
    <f:link.action action="list" addQueryString="&tx_news_pi1[orderBy]=title&tx_news_pi1[sort]=desc">Sort by title: desc</f:link.action>
    
    流体:

    #######
    ## Here you transfer the URL-parameters for sorting to the TypoScript-settings
    ## and also assure that only predefined values are accepted
    #######
    [globalVar = _GET|tx_news_pi1|orderBy = title]
        plugin.tx_news.settings.orderBy = title
    [globalVar = _GET|tx_news_pi1|orderBy = datetime]
        plugin.tx_news.settings.orderBy = datetime
    [globalVar = _GET|tx_news_pi1|orderBy = tstamp]
        plugin.tx_news.settings.orderBy = tstamp
    [globalVar = _GET|tx_news_pi1|orderBy = crdate]
        plugin.tx_news.settings.orderBy = crdate
    [global]
    
    [globalVar = _GET|tx_news_pi1|sort = desc]
        plugin.tx_news.settings.orderDirection = desc
    [else]
        plugin.tx_news.settings.orderDirection = asc
    [global]
    
    <f:link.action action="list" addQueryString="&tx_news_pi1[orderBy]=title&tx_news_pi1[sort]=asc">Sort by title: asc</f:link.action>
    <f:link.action action="list" addQueryString="&tx_news_pi1[orderBy]=title&tx_news_pi1[sort]=desc">Sort by title: desc</f:link.action>
    
    按标题排序:asc
    按标题排序:desc
    
    此解决方案未经测试,可能仍需要对某些内容进行调整,但总体而言,它应该可以正常工作。
    与缓存相关的问题通常被认为与新闻记录相同,至少与任何必需的设置相关。
    按其他字段排序需要执行以下步骤:

  • 其他单独的解决方案需要使用PHP编程,并且可以基于钩子和信号,新闻手册包含了可能有用的几个章节:

  • 此外,可能已经存在解决排序任务的扩展,但我不知道。你可以搜索。我可以想象,或者可能有用,但我从来没有检查过,这些扩展可能根本就不会有用。
    此外,您还可能在进一步搜索中发现另一个有用的扩展。如果是,请告诉我们;-)

  • 然后仍然有一个选择,以某种方式,期望的行为可以得到不同的解决,也许它没有被记录或记录不好,或者我错过了它


  • 考虑一下,如果使用分页,您可能还需要做一些调整,尤其是。

    我找到了问题的原因和解决方法

    原因是flexform中的默认排序:按标题排序。GET参数orderBy无法覆盖flexform中的默认排序。如果在flexform中选择默认排序,则orderBy参数ist将被忽略,但orderDirection参数将按预期工作。结果令人困惑,但却是一致的:内容列表始终按默认排序,但排序方式不同

    删除flexform中的默认排序后,所有工作按预期进行


    我想这是一种虫子;我将在新闻的bug跟踪器中发布一个问题

    tx\u news\u pi1[overwritedmand][order]=title desc
    对我有效

    这不再有效(尽管以前有效)。您必须使用Georg Ringer已经提到的tx_news_pi1[OverwritedMand][order]=标题描述。