0

I have an extension containing a action for an ajax call, which returns a json string. There is also a plugin inserted on a specific page for the user input. The plugin has some settings (via flexform), which I want to get at the ajax call, but I have no idea how.

ajaxCall = PAGE
ajaxCall {
    typeNum = 1000
    config {
        disableAllHeaderCode = 1
        metaCharset = UTF-8
        no_cache = 1
        debug = 0
    }

    10 = USER
    10 {
        userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
        vendorName = Vendor
        pluginName = SomePlugin
        extensionName = SomeExtension
        controller = MyController
        action = ajax
        switchableControllerActions {
            MyController {
                1 = ajax
            }
        }
    }
}
Ralf
  • 836
  • 1
  • 9
  • 32

3 Answers3

1

That is a perfect use case for https://extensions.typo3.org/extension/typoscript_rendering/ Create a link to the action you want to call via Ajax using the delivered view helper and your action renders exactly as expected (including flexform content being respected).

helhum
  • 453
  • 2
  • 12
  • Can you help me? https://stackoverflow.com/questions/59000554/how-use-exttyposcript-rendering-with-extfrom-in-typo3 ..., please. – TYPO3UA Nov 22 '19 at 19:29
0

I see two possibilities to solve your problem:

  1. put the uid of the plugin (which is a content element and so represented by a record in the table tt_content) in the parameters of your call to the controller so the controller can read that record and get the data.

or

  1. instead of a call to the controller render the plugin explicitly.
    Depending on the configuration of the page where the plugin is stored you might render the whole page, column or only the content element. (use the CONTENT object in your typoscript.)
Bernd Wilke πφ
  • 10,390
  • 1
  • 19
  • 38
0

Thanks, I tried something like 2. but I've got the problem, that I get also the headline and the wrap, which is unpractical for a json output

....
#page Type 1000
10 = CONTENT
10 {
    table = tt_content
    select {
        where = list_type="someextension_someplugin"
    }
...
Ralf
  • 836
  • 1
  • 9
  • 32
  • 1st: don't use answers as reply. add it to your question stating what you have tried so far. 2nd: then I can add to my answer: you might change the global rendering for the Ajax pagetype (I assume FSC, where you can change the layout file(s)) – Bernd Wilke πφ May 02 '19 at 11:20
  • aw sorry, I will add it to the question next time – Ralf May 02 '19 at 11:25
  • do you have some hint to change the global rendering for this pagetype? I could'nt find any example. Thanks – Ralf May 02 '19 at 13:06
  • depending on the usage of CSC or FSC you need to change typoscript or fluid-templates (probably a *Layout*): build in a condition based on the page type (URL-parameter `type` respectively the attribute of the `pages` record) which decides whether the wrapping is rendered or not. – Bernd Wilke πφ May 02 '19 at 13:33