[TYPO3-dev] Data Exchange between two plugins within the same extension

bernd wilke xoonsji02 at sneakemail.com
Thu Jan 24 14:54:48 CET 2008


on Thu, 24 Jan 2008 11:24:49 +0100, Ansgar Brauner wrote:

> bernd wilke schrieb:
>> why this split?
>> 
>> maybe you can manage all in one single plugin and you won't have to
>> bother about changing prefixes
>> 
>> something like:
>> 
>> function main (...) {
>> 	[...]
>> 	if ($mode == 1) {
>> 		$this->displayView1(...);
>> 	} else {
>> 		$this->displayView2(...);
>> 	}
>> }
>> 
>> and you may have two separates files for defining these functions
>> 
>> 
>> Bernd
>> 
>> 
> Hi Bernd,
> 
> because i have to switch several times. First i will have a
> switch-statement in the main() Method. But to create, read, update or
> delete an object on the second page i have to switch in the those
> methods again. The Code is getting really confusing.
> 
> So the main problem seems to be, that i dont want to switch at several
> positions.
> 
> So at the moment i do a switch in the main method and in every
> displayAnything().

this can be a good way to be very flexible, but so you don't want/need it 
you can implement this functions with different names in different ways.

you may do this in different files having all functions of one view in a 
file by it's own.
the connection is the normal file class.myextension_pi1.php:

 :
require_once(PATH_tslib.'class.tslib_pibase.php');
class tx_myextension_pi1 extends tslib_pibase {
	:

        function main($content, $conf){
		:
		if ($mode == 1) {
 			$this->displayView1(...);
	 	} else {
 			$this->displayView2(...);
	 	}

	}

	include_once(t3lib_extMgm::extPath('myextension').'view1.php');

	include_once(t3lib_extMgm::extPath('myextension').'view2.php');

}

you can have (nearly) the same names but different implementations

and the two files are like this:
in view1.php:

function displayview1() { ... }
function v1_selectRecords() { ... }
function v1_displayList() { ... }
:

in view2.php:

function displayview2() { ... }
function v2_selectRecords() { ... }
function v2_displayList() { ... }
:

so the includes are inside the class definition the functions of 
view1.php and view2.php are inside the class and share the same class and 
other parameters. In the 'normal' file class.tx_myextension_pi1.php you 
just have the switch about which functions are to be used for the rest of 
page-generation.

Bernd

-- 
http://www.pi-phi.de/t3v4/cheatsheet.html




More information about the TYPO3-dev mailing list