[TYPO3-mvc] Filter plugin in different Controller / content element

typo3 at litedesigns.nl typo3 at litedesigns.nl
Fri Mar 2 14:14:09 CET 2012


Hi all,

First i want want thank Daniel and Claus for their suggestions.

I've stumbled upon another solution which works as well. After posting my
question to the list i started to work on some other areas of my plugin
where i needed to be able to set a different default controller action for
different instances of the plugin.

I have setup a flexform for my Company plugin where i configured some
default actions. The flexform is defined in ext_tables.php I removed my
FilterController and my template in
Resources/Private/Templates/Filter/Show.html

I created a new function my CompanyController to show the filters template:
/**
 * action showFilters
 *
 * @param Tx_MyExt_Domain_Model_Demand $demand
 * @return void
 */
public function showFiltersAction(Tx_MyExt_Domain_Model_Demand $demand =
NULL)
{
	$this->view->assign('demand', $demand);
}

And new template in Resources/Private/Templates/Company/ShowFilters.html
with the form:

<f:form class="tx-my-ext-companies" method="post" name="demand"
object="{demand}">
	<tr>
		<td valign="top" ><noscript><f:form.submit
value="Filteren"/></noscript></td>
		<td valign="top" ><f:form.textbox id="searchWord" property="searchWord"
style="width: 200px;" additionalAttributes="{onChange :
'document.demand.submit();'}" /></td>
	</tr>
</f:form>

Note that the action="list" param of the form has been removed (since it
is not defined in the flexform under 'Show Company Filters' it is not
allowed)! But if we would add action="list" and configured the flexform
with the list action, the plugin in the sidebar would also list the
results after the search form is submitted...

ext_tables.php
$pluginSignature = str_replace('_','',$_EXTKEY) . '_companies';
$TCA['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature]
= 'pi_flexform';
t3lib_extMgm::addPiFlexFormValue($pluginSignature, 'FILE:EXT:' . $_EXTKEY
. '/Configuration/FlexForms/flexform_companies.xml');

And the flexform itself:
<T3DataStructure>
	<sheets>
		<sDEF>
			<ROOT>
				<TCEforms>
					<sheetTitle>Options</sheetTitle>
				</TCEforms>
				<type>array</type>
				<el>
					<switchableControllerActions>
						<TCEforms>
							<label>Default action of the plugin</label>
							<config>
								<type>select</type>
								<items>
									<numIndex index="0">
										<numIndex index="0">List Companies</numIndex>
										<numIndex index="1">Company->list</numIndex>
									</numIndex>
									<numIndex index="1">
										<numIndex index="0">Show single Company</numIndex>
										<numIndex index="1">Company->show</numIndex>
									</numIndex>
									<numIndex index="2">
										<numIndex index="0">Show Company Filters</numIndex>
										<numIndex index="1">Company->showFilters</numIndex>
									</numIndex>
								</items>
							</config>
						</TCEforms>
					</switchableControllerActions>
				</el>
			</ROOT>
		</sDEF>
	</sheets>
</T3DataStructure>

This way i can add the Company plugin in the sidebar and select the third
option (Show Company Filters) which renders the showFilters.html template.
And in my main content area i add the Company plugin with the first option
(List Companies). I'm not entirely sure why this works, but i suppose it
has something to do with 'staying in the same frontend plugin' :)

Kind regards,
Tim

ps. my outlook removed the incoming lists messages from the server and i
can't post a new message from outlook, so if this message is not added to
the thread correctly, my appologies. This solution belongs to this
original question:
http://lists.typo3.org/pipermail/typo3-project-typo3v4mvc/2012-March/011880.html



More information about the TYPO3-project-typo3v4mvc mailing list