[TYPO3-dev] Problem with changing query according to post-parameter
David Bruchmann
typo3-dev at bruchmann-web.de
Sat Aug 1 10:38:45 CEST 2009
>>> ----- Ursprüngliche Nachricht -----
>>> Von: Walter Seeberger <walk2moon at gmx.de>
>>> Gesendet: Freitag, 31. Juli 2009 14:14:51
>>> An: typo3-dev at lists.netfielders.de
>>> CC:
>>> Betreff: [TYPO3-dev] Problem with changing query according to
>>> post-parameter
>>>> Hello there,
>>>>
>>>> I try to react upon some post-parameters by changing data according to
>> that in the model.ok:
>>>> first I am doing some query and print the result trough my
>> template.works!:
>>>> <?php if($this->isNotEmpty()) { ?>
>>>> <ul>
>>>> <?php } ?>
>>>> <?php for($this->rewind(); $this->valid(); $this->next()) {
>>>> $entry = $this->current();
>>>> ?>
>>>> <li><?php $entry->printAsText('name'); ?></li>
>>>> <?php } ?>
>>>> <?php if($this->isNotEmpty()) { ?>
>>>> </ul>
>>>> <?php } ?>
>>>>
>>>>
>>>> Now I am using my form to put in some param. My template calls this
>> function in the controller:
>>>> public function formCallAction(){
>>>> $modelClassName =
>> tx_div::makeInstanceClassName('tx_testext_model_data');
>>>> $model = new $modelClassName($this);
>>>> $model->load($this->parameters);
>>>>
>>>> $view = tx_div::makeInstance('tx_testext_view_resultlist');
>>>> $view->exchangeArray($this->parameters);
>>>> $view->controller($this);
>>>> $view->render($this->configurations->get('resultlist'));
>>>>
>>>> $className =
>> tx_div::makeInstanceClassName('tx_lib_translator');
>>>> $translator = new $className($this, $view);
>>>> return $translator->translateContent();
>>>> }
>>>>
>>>> The result is: Fatal error: Call to a member function printAsText() on
>> a non-object ... /template.php in line 9.
>>>> Is anyone able to help me with this problem?
>>>> Need some ;-)
>> ----- Ursprüngliche Nachricht -----
>> Von: David Bruchmann <typo3-dev at bruchmann-web.de>
>> Gesendet: Freitag, 31. Juli 2009 18:28:19
>> An: List for Core-/Extension development
>> <typo3-dev at lists.netfielders.de>
>> CC:
>> Betreff: Re: [TYPO3-dev] Problem with changing query according to
>> post-parameter
>>>
>>> Hi Walter first of all I propose to write the php like this:
>>
>> if($this->isNotEmpty()) {
>> $content='<ul>';
>> for($this->rewind(); $this->valid(); $this->next()) {
>> $content.= '<li>';
>> $content.= $this->printAsText( $this->current() ); ##
>> $content.= '</li>';
>> }
>> $content .='</ul>';
>> echo $content;
>> }
>>
>> ?>
>>
>>> Concerning your problem have a look at line with the ## at the end.
>>> I'm not sure, but $this->current() logically has no function
>>> printAsText().
----- Ursprüngliche Nachricht -----
Von: Walter Seeberger <walk2moon at gmx.de>
Gesendet: Samstag, 1. August 2009 09:59:29
An: List for Core-/Extension development
<typo3-dev at lists.netfielders.de>
CC:
Betreff: Re: [TYPO3-dev] Problem with changing query according to
post-parameter
Hello Walter,
> thank you for your answer. The thing you mentioned with changing the
php style is absolutely correct. Much better to read. But when I changed
to your example, I get an Illegal offset type in spl object.
Ok, I didn't test it, and I didn't use the construct with $valid(),
$next() and current() before. The Illegal offset type in spl object
will disappear after my next hint.
>
> Ok, the main problem is the following:
>
> 1. I run the first time my controller action:
> The list with results appears.
>
> 2. I type something in my form and send it.
> the params are stored in the $POST and they are accessible.ok.
> BUT
> now there is no further list with results.
>
> When I set an exchangeArray in my controller_action this way:
> $view->exchangeArray($this->parameters);
> I get this Fatal error: Call to a member function printAsText() on
>> a non-object ... /template.php in line 9.
>
> Without, simply there is no result list (no content object in the html)!
ok, find the classname under which the class with the function
printAsText() is intantiated inside the $view-class and then call the
function printAsText() inside the discussed loop like this:
$content.= $CLASSNAME->printAsText( $this->current() );
'CLASSNAME' has to be replaced against the real Instance-Name.
If you can't find the function printAsText() you have to write one.
Best Regards
David
More information about the TYPO3-dev
mailing list