[TYPO3-UG Cambodia] TYPO3 : Call a function in Other Class
Visay Keo
typo3 at visay.info
Sat Jan 1 14:42:00 CET 2011
Hi Chanratha,
I don't see what you have in your template file but I suggest you make
some changes to the template as the following example:
<!-- ###REGISTRATION_FORM### begin -->
<form action="###FORM_ACTION###" method="post">
<label for="firstname">###FIRSTNAME_LABEL###</label>
<input type="text" id="firstname"
name="tx_extensionname_pi1[firstname]" value="###FIRSTNAME###" /><br />
<label for="lastname">###LASTNAME_LABEL###</label>
<input type="text" id="lastname"
name="tx_extensionname_pi1[lastname]" value="###LASTNAME###" /><br />
<input type="submit" name="tx_extensionname_pi1[submit]"
value="###BTN_SUBMIT_LABEL###" title="###BTN_SUBMIT_LABEL###" />
</form>
<!-- ###REGISTRATION_FORM### end -->
In the template, just have the LABEL, VALUE and FORM ACTION as markers.
Other things beside this that always remain the same just put it fixed
in the template file.
Then in you plugin class just replace the marker of FORM ACTION and
LABEL and VALUE of each field.
/**
* Displays the form
* @return string The form content
*/
function showForm() {
$template = $this->cObj->getSubpart($this->template,
'###REGISTRATION_FORM###'); // You must already have $this->template
variable set to the location of the template file. Use the function
$this->cObj->fileResource('EXT:extension_key/res/template.html');
$markerArray = array(); // Declare an array for storing markers
$markerArray['###FORM_ACTION###'] =
$this->pi_linkTP_keepPIvars_url(array(), 0, 1, 0); // Generate link for
the form action marker array
..... Code to assign value to marker array of each field label and
value come in here .....
return $this->cObj->substituteMarkerArrayCached($template,
$markerArray); // Replace all the marker array and return
}
Hope this helps.
Cheers,
Visay
On 12/27/2010 08:43 AM, Chanratha LY wrote:
> Dear Mr. Visay,
>
> Please take a look to the code of my function below:
>
> function user_registration () {
> $markerArray['###FORM_ATTRIB###'] = ' method="post" action="'.
> $this->pi_linkTP_keepPIvars_url(array(), 0, 1, 0).'"';
> $markerArray['###USER_NAME###'] = $this->prefixId.'[user_name]';
> $markerArray['###PWD###'] = $this->prefixId.'[pwd]';
> $markerArray['###REGISTER_SUBMIT###'] =
> $this->prefixId.'[register_submit]';
>
> $content =
> $this->cObj->substituteMarkerArrayCached($this->user_registration_form,$markerArray);
> return $content;
> }
>
> *Chanratha LY (Mr.)*
> *_________________*
> Job: Developer
> Company: Yejj Group
> H/P: + 855 (0) 23 22 44 00
> Tel : + 855 (0) 97 98 92 64 9
> Website: http://www.yejj.com
>
>
>
> On Sun, Dec 26, 2010 at 6:00 PM,
> <typo3-ug-cambodia-request at lists.typo3.org>wrote:
>
>> Send TYPO3-UG-Cambodia mailing list submissions to
>> typo3-ug-cambodia at lists.typo3.org
>>
>> To subscribe or unsubscribe via the World Wide Web, visit
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-ug-cambodia
>> or, via email, send a message with subject or body 'help' to
>> typo3-ug-cambodia-request at lists.typo3.org
>>
>> You can reach the person managing the list at
>> typo3-ug-cambodia-owner at lists.typo3.org
>>
>> When replying, please edit your Subject line so it is more specific
>> than "Re: Contents of TYPO3-UG-Cambodia digest..."
>>
>>
>> Today's Topics:
>>
>> 1. Re: How to call a function in other class which return the
>> form? (Visay Keo)
>>
>>
>> ----------------------------------------------------------------------
>>
>> Message: 1
>> Date: Sun, 26 Dec 2010 12:38:11 +0700
>> From: Visay Keo<typo3 at visay.info>
>> Subject: Re: [TYPO3-UG Cambodia] How to call a function in other class
>> which return the form?
>> To: typo3-ug-cambodia at lists.typo3.org
>> Message-ID:
>> <mailman.1.1293341961.3190.typo3-ug-cambodia at lists.typo3.org>
>> Content-Type: text/plain; charset=UTF-8; format=flowed
>>
>> Hi Chanratha,
>>
>> Maybe it's easier if you can show us the code of the "user_registration"
>> function.
>>
>> Cheers,
>> Visay
>>
>> On 12/24/2010 09:45 AM, Chanratha LY wrote:
>>> Dear Typo3Cambodia Members,
>>>
>>> I have met one problem and would like to ask all of you.
>>>
>>> I have two classes, A& B.
>>> Class A has a function "user_registration" which returns the registration
>>> form.
>>>
>>> In B, I would like to call function "user_registration" from class A. It
>>> work well if function "user_registration" returns value.
>>> *Problem:*
>>> It does not work for if function "user_registration" return the form. The
>>> message is: *Fatal error**: Call to a member function typoLink() on a
>>> non-object in **
>>>
>> /home/public_html/first_test/typo3/sysext/cms/tslib/class.tslib_pibase.php**on
>>> line
>>> **309.*
>>>
>>> Thanks,
>>> Chanratha
>>
>>
>> ------------------------------
>>
>> _______________________________________________
>> TYPO3-UG-Cambodia mailing list
>> TYPO3-UG-Cambodia at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-ug-cambodia
>>
>> End of TYPO3-UG-Cambodia Digest, Vol 2, Issue 7
>> ***********************************************
>>
More information about the TYPO3-UG-Cambodia
mailing list