Fidi
Fidi

Reputation: 5834

Call specific extbase action for plugin

I am developing a TYPO3 Extbase-Extension, which fetches events from an XML-API. The Extension consists of 1 controller and 2 actions.

So my ext_localconf.php looks somewhat like this:

Tx_Extbase_Utility_Extension::configurePlugin($_EXTKEY, 'pi1', array(
    'Api' => 'latest,full'
),
array(
    'Api' => 'latest,full'
));

The contents of the actions are almost the same, the latest-Action fetches only 3 events from the API, the full-Action fetches all events from the API. Also they do render the events a bit differently, meaning they use different templates.

Now in the TYPO3-Backend on Page AI'm adding a new content with type of plugin. I select my plugin save the content. In the frontend the results produced by the latest-Action of the plugin are output.

However on Page B, I also want to use the same plugin, but want to output the results of the full-Action.

I am kinda confused. How can I select the action in a dropdown in the backend or something?

Documentation on TYPO3 is really bad and lacks lots of information, so I am looking here for help.

All examples that I found only deal with one action.

Upvotes: 1

Views: 393

Answers (1)

Andrei Todorut
Andrei Todorut

Reputation: 4526

You have to create a flexform for the plugin , or if your plugin has a flexform now just add the following.

To be able for choosing the actions and controller within a plugin you need to use switchableControllerActions in flexform.

<switchableControllerActions>
    <TCEforms>
         <label>View</label>
         <onChange>reload</onChange>
         <config>
           <type>select</type>
           <items type="array">
               <numIndex index="1" type="array">
                 <numIndex index="0">Latest events</numIndex>
                 <numIndex index="1">Api->latest;</numIndex>
               </numIndex> 
               <numIndex index="1" type="array">
                 <numIndex index="0">All events</numIndex>
                 <numIndex index="1">Api->full;</numIndex>
               </numIndex>               
            </items>
         </config>
     </TCEforms>
</switchableControllerActions>

If you don't have a flexform for extension create one in Configuration/Flexform folder. Check this link. https://wiki.typo3.org/Extension_Development,_using_Flexforms

Upvotes: 1

Related Questions