[TYPO3-formidable] access parent PluginObject in ajax list

Jérôme Schneider mail at jeromeschneider.fr
Sat Jan 15 09:00:00 CET 2011


Hi All,
I use another option usually, and it's based on the fact that in the 
ajax context, the only objects that are maintained after page load and 
across successive events are the codebehind objects.

To declare a PHP codebehind object, apply these instructions:
http://formidable.typo3.ug/features/codebehind-syntax.html

If an init() method is declared in your CB class, the system will call 
it only one time, when the object is forged during page generation.
This gives you an opportunity to store locally in you CB objects 
variables that belong to the parent plugin for instance.

An example:
class mycodebehind {
   function init() {
     $this->aFlexConf = $this->oForm->oParent->cObj->data["pi_flexform"];
   }

   function btnHello_click() {
     // this will work :)
     return $this->majixDebug($this->aFlexConf);
   }
}


Now if what you need is a method, you'll have to externalize your needed 
parent method in an autonomous library and load it in both the parent 
and your codebehind, to be able to call it from the two contexts 
(pageload and ajax).


NOTE: depending on you version you may also define another magic method 
named initAjax() that is called when the object is unhibernated from 
session.

I hope this will clarify a bit.

Best regards,
Jérôme Schneider

On 13/01/11 17:37, Markus Lange wrote:
> Oliver Klee schrieb:
>
>> I had the same problem and concluded that there just is no parent cObj
>> when processing an AJAX call.
>
> thanks for your anwser!
> i found a solution:
> in the normal list used something like
>
> return $this->_oParent->MethodName($params);
> eg:
> return
> $this->_oParent->createDetailLink($aRowData['title'],$aRowData['uid']);
>
>
> the list got refreshed via ajax with an error:call func with non object
>
> i replced the call with the method itself (not really fine) but works:
>
> ...
> $the_link = $this->cObj->typolink('Eintrag lesen und bewerten',
> $temp_conf);
> return $the_link;
> and this works
>
>
>
>



More information about the TYPO3-project-formidable mailing list