TYPO3 Ajax Page Configuration

给你一囗甜甜゛ 提交于 2019-12-14 01:40:57

问题


How can I remove the CSS Styled conted header output from a Ajax Page in TYPO3?

This is my Typoscript:

ajax = PAGE
ajax {
  typeNum = 1234
  # this solution is working, but then I don't have flexform values
  # 10 < tt_content.list.20.myextension_pi1

  10 < styles.content.get
  10 {
    select.where = colpos = 0
    select.andWhere = list_type='myextension_pi1'     
  }

  config {
    disableAllHeaderCode = 1
    additionalHeaders = Content-type:application/json
    xhtml_cleaning = 0
    admPanel = 0
    debug = 0
    no_cache = 1
  }
}

This is my Ajax Result - Hello World is tt_content header:

<h2 class="csc-firstHeader">Hello World</h2>{"valid":false}

I tried already without success:

lib.stdheader > 
lib.header >

And this will affect ALL page types, and for standard output I want to keep tt_content header output.


回答1:


You should not place tt_content element containing the plugin, but plugin itself, like:

ajax = PAGE
ajax {
  typeNum = 1234

  10 < plugin.myextension_pi1     

  config {
    disableAllHeaderCode = 1
    additionalHeaders = Content-type:application/json
    xhtml_cleaning = 0
    admPanel = 0
    debug = 0
    no_cache = 1
  }
}

see also similar question

You don't need to modify CSC in this case.

Of course in such case you need to make your extension configurable via TS (preferably with option for merging TS config with FlexForm, like this)

Alternative:

  • You can also create a new page (let's name it Voucher page) - put the tt_conent with your flexform there.
  • Get its uid (let's say it's 123) and add it to ajax link ie.: index.php?id=123&type=1234
  • At the page create empty TypoScript template (not root!) and in Settings field remove all formattings from CSC (as you showed us)

    lib.stdheader > 
    lib.header >
    etc...
    

You can also use TypoScript conditions for clearing CSC on given pages only ie.

[globalVar = TSFE:id = 123]
    lib.stdheader > 
    lib.header >
[end]

or for type parameter only (I read somewhere that there was a bug with it, but not confirmed, so it should work as well):

[globalVar = GP:type = 1234]
    lib.stdheader > 
    lib.header >
[end]



回答2:


Depending on the use case for the AJAX calls I would also consider using eID scripts for AJAX calls instead of page type.

This is at least my preference in most cases.

See here: Typo3 Extbase AJAX without page typenum




回答3:


AJAX Page type

tmp.ajaxConf = PAGE
tmp.ajaxConf {
    typeNum = 1249058000
    config {
        disableAllHeaderCode = 1
        xhtml_cleaning = 0
        admPanel = 0
    }
}

ajax_fullPage < tmp.ajaxConf
ajax_fullPage {
    typeNum = 1234567890
    10 < styles.content.get
}

AJAX

var _currentURL = window.location; // Current URL Path
$.ajax({
    url: _currentURL,
    data: '&type=1234567890',
    cache:false,
    success: function(result) {
        // Code
    },
    error: function(result) {
        alert('Error');
    }
});


来源:https://stackoverflow.com/questions/21884878/typo3-ajax-page-configuration

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!