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 小程序中fit格式等运动数据文件怎样实现可视化?(包含心率信息))
  • ¥15 如何利用mmdetection3d中的get_flops.py文件计算fcos3d方法的flops?
  • ¥40 串口调试助手打开串口后,keil5的代码就停止了
  • ¥15 电脑最近经常蓝屏,求大家看看哪的问题
  • ¥60 高价有偿求java辅导。工程量较大,价格你定,联系确定辅导后将采纳你的答案。希望能给出完整详细代码,并能解释回答我关于代码的疑问疑问,代码要求如下,联系我会发文档
  • ¥50 C++五子棋AI程序编写
  • ¥30 求安卓设备利用一个typeC接口,同时实现向pc一边投屏一边上传数据的解决方案。
  • ¥15 SQL Server analysis services 服务安装失败
  • ¥15 基于面向对象的图书馆借阅管理系统
  • ¥15 opencv图像处理,需要四个处理结果图