weixin_33738578 2019-05-14 10:10 采纳率: 0%
浏览 41

Typo3 9.x Ajax调用

Configuration about a single route for ajax call: getamministrazioni.json

I tried to change configuration site as follow:

...


    routeEnhancers:
      News:
        type: Extbase
        extension: News
        plugin: Pi1
        routes:
          -
            routePath: '/{news-title}'
            _controller: 'News::detail'
            _arguments:
              news-title: news
        aspects:
          news-title:
            type: PersistedAliasMapper
            tableName: tx_news_domain_model_news
            routeFieldName: path_segment
      PageTypeSuffix:
        type: PageType
        default: .html
        map:
          .html: 0
          getamministrazioni.json: 1035343

    errorHandling: {  }
    routes: {  }
...

And in setup.typoscript i have:

GetAmministrazioni = PAGE
GetAmministrazioni {
typeNum = 1035343
config {
    disableAllHeaderCode = 1
    debug = 0
    no_cache = 1
    additionalHeaders {
      10 {
        header = Content-Type: application/json
        replace = 1
      }
    }
}
 10 < tt_content.list.20.my_controller_getamministrazioni

}

It works but for all pages.

  1. /home/getamministrazioni.json
  2. /page1/getamministrazioni.json

etc.. etc..

I want a single route from root '/getamministrazioni.json

how i can do that?

  • 写回答

2条回答 默认 最新

  • weixin_33701251 2019-05-14 21:31
    关注

    There is a possibility to limit the routing to specific page ids:

    limitToPages: 1
    

    But this will limit your whole mapping configuration to page id 1, also the .html suffix (which you don't want to, I guess).

    Unfortunately, it is currently not possible to create multiple Route Enhancers with the same name, like in the following, non-working example:

    PageTypeSuffix:
      type: PageType
      map:
        .html: 0
    PageTypeSuffix:
      type: PageType
      limitToPages: 1
      map:
        sitemap.xml: 1533906435
    

    Two possible workarounds:

    1. Create your own RouteEnhancer, which just extends TYPO3\CMS\Core\Routing\Enhancer\PageTypeDecorator to allow a different name (see custom enhancers)

    2. Redirect your json page type to an error page, if page id is not 0 (no routing neccessary, as TypoScript avoids delivering of this page type)

      [getTSFE().id != 1] seo_sitemap.config { additionalHeaders.10 { header = Location: /error.html } } [END]

    评论

报告相同问题?

悬赏问题

  • ¥15 is not in the mmseg::model registry。报错,模型注册表找不到自定义模块。
  • ¥15 安装quartus II18.1时弹出此error,怎么解决?
  • ¥15 keil官网下载psn序列号在哪
  • ¥15 想用adb命令做一个通话软件,播放录音
  • ¥30 Pytorch深度学习服务器跑不通问题解决?
  • ¥15 部分客户订单定位有误的问题
  • ¥15 如何在maya程序中利用python编写领子和褶裥的模型的方法
  • ¥15 Bug traq 数据包 大概什么价
  • ¥15 在anaconda上pytorch和paddle paddle下载报错
  • ¥25 自动填写QQ腾讯文档收集表