[TYPO3-english] Using variable in $addWhere select statement

christian oettinger christian.oettinger at gmx.de
Thu Jan 10 17:27:18 CET 2013


Hi Adrian,

We forget about why you are doing it the way you do and assume you have 
good reason. I also understand that you are using piBase to develop your 
extension. I'll write detailed, for it may help other people too.

a) Usually you are in one plugin (pi1) in one extension (ext1). You are 
in one function (listView) and create links to call the plugin again 
with a parameter in URL (e.g. tx_ext1_pi1[showUid]=12). TYPO3 detects 
the parameter and because of it redirects to another function (singleView).
TYPO3 also takes the parameter and puts it into $this->piVars (in our 
case you cann access $this->piVars['showUid'] qhile in pi1 of ext1).
To create the links you usually use a funciton like pi_list_linkSingle. 
This function is written to do exactly the above: jumping to singleView 
in the same plugin. The parameters in the URL are created exactly for 
that purpose.

b) You want jump from pi1 of ext1 to pi1 of ext2. So you don't need the 
following (Standard-)URL:
www.qqq.com/Index.php?id=15&tx_ext1_pi1[showUid]=388
but:
www.qqq.com/Index.php?id=15&tx_ext2_pi1[showUid]=388

To gereate URLs like this so, you just have to use another function for 
generating the links in listView, e.g. pi_linkToPage. Here you can 
define your parameters freely. A working example should be:


$urlParameters = array(
   'tx_ext2_pi1[showUid]' => $targetRecordUid,
   'tx_ext2_pi1[anotherParameter]' => $whatEver
);
$link = $this->pi_linkToPage($linktext, $targetpage, '',$urlParameters);

c) Then you can again use $this->piVars (this time in pi1 of ext2) to 
access the parameters 'shwoUid' or 'anotherParameter' and put them into 
your $addWhere.


hope this helps
greetings!
christian (oe)




 > I have 2 extensions on different pages.
 >
 > List view is rendered by extension_1
 >
 > Single view is rendered by extension_2
 >
 > I`m transferring a variable from list to single in url:
 >
 > 
www.qqq.com/Index.php?tx_ext1_pi1[showUid]=388<http://www.qqq.com/Index.php?tx_ext1_pi1%5bshowUid%5d=388>
 >
 >
 >
 > in second extension I need to add this variable to $addWhere in my select
 > query. How to add it do $addWhere?
 >
 >
 > Adrian
 >


> I have 2 extensions on different pages.
>
> List view is rendered by extension_1
>
> Single view is rendered by extension_2
>
> I`m transferring a variable from list to single in url:
>
> www.qqq.com/Index.php?tx_ext1_pi1[showUid]=388<http://www.qqq.com/Index.php?tx_ext1_pi1%5bshowUid%5d=388>
>
>
>
> in second extension I need to add this variable to $addWhere in my select
> query. How to add it do $addWhere?
>
>
> Adrian
>



More information about the TYPO3-english mailing list