[TYPO3-dev] Problem with changing query according to post-parameter

David Bruchmann typo3-dev at bruchmann-web.de
Fri Jul 31 18:35:53 CEST 2009


----- 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
> ----- 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 ;-)
> 
> 
> Hi Walter first of all I propose to write the php like this:
> 
> <?php
> 
> if($this->isNotEmpty()) {
> 	$content='<ul>';
> 	for($this->rewind();
> 		$this->valid();
> 		$this->next()) {
> 			$content.='<li>';
> 			$this->printAsText( $this->current() );  ##
> 			$content.='</li>';
> 		}
> 	}
> 	$content .='</ul>';
> 	echo $content;
> }
> 
> ?>
> 
> It's a lot clearer to read and I think avoids some faults.
> 
> 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().
> 

Sorry, made a fault by myself:

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;
}

?>

Best regards
David





More information about the TYPO3-dev mailing list