RSS 2.0
RSS 0.91
ATOM 0.3
May 22, 2013

Howto: Share variables between extension plugins

Category: Extbase

By: Stefan Frömken

Have you ever needed to use some parameters from one plugin in another, without the possibility to send them over? Here is a way:

Hello TYPO3-Community,

in a current project we have a search result plugin (tx_myext_results) in center col and the search form (tx_myext_searchform) in right col.

When submitting the search form we need the informations in right col to show the submitted values in form again and we need the same information for our result list to show the needed results.

The problem is: You can define only ONE resulting plugin in f:form-ViewHelper. So, if I set it to my result plugin the question appears how to access the same information for my search plugin. In more detail: How to access informations from tx_myext_results within the search plugin that can only access tx_myext_search?

I found a solution with help of an initializeAction:

 * preprocessing for all actions
 * @return void
protected function initializeAction() {
     // register foreign argument for search action
     $foreignPluginContext = t3lib_div::_POST('tx_myext_results');
     if (isset($foreignPluginContext['search'])) {
          $search = $foreignPluginContext['search'];
          if (is_array($search) && count($search)) {
               $this->request->setArgument('search', $search);

Now our request has a new Argument called search. So now it's time to access this argument in searchAction:

 * action search
 * @param Tx_MyExt_Domain_Model_Search $search
 * @return void
public function searchAction(Tx_MyExt_Domain_Model_Search $search = NULL) {
     $this->view->assign('search', $search);

As you can see we haven't made any modifications to our searchAction. But in $search variable we have a complete aggregate root object from the foreign plugin.


comment #1
Gravatar: Maba Maba May 22, 2013 19:53
plugin.tx_myext_searchform.view.pluginNamespace = tx_myext_results
[..] most cases using pluginNamespace you also need to set
plugin.tx_myext_searchform.mvc.callDefaultActionIfActionCantBeResolved = 1

Sorry, comments are closed for this post.