[TYPO3-ect] Copying data from the model to teh view....

Steffen Kamper steffen at dislabs.de
Sat Mar 3 21:10:25 CET 2007


"R. van Twisk" <typo3 at rvt.dds.nl> schrieb im Newsbeitrag 
news:mailman.51940.1172950493.21067.typo3-team-extension-coordination at lists.netfielders.de...
> Modeñ views...
>
> Hey Guys,
>
> I have a small question...
>
> Currently I have this in my code...
>
>
>                $model = 
> tx_div::makeInstance('tx_absgalleries_model_dummy');
> 
> //$model->setConfigurations($this->configurations);
>                $model->load($this->parameters);
>                $resultList = $model->get('resultList');
>                $view = 
> tx_div::makeInstance('tx_absgalleries_views_exhibition');
>                $view->init();
> 1)              $view->set('entryList', $resultList);
> 2)              $view->set('price', $model->get('price'));
>
>
>
> As you can see my model get's initialized and data is set using set 
> methods (in 1 and 2),
> all fine...
>
> However setting the data to my view I need to call set(..) for each single
> value.
>
> Isn't it possible to assign the complete dataset from  the model to the 
> view directly using a copy constructor or something?
>
> Or using something like this...
>
>     $view->set($model);
>
> within the view, model could even be a reference which will save
> copying some data around.
>
> thanks,
> Ries
>
>
Hi Ries,

look at Elmar's eFaq. he uses the lib-object to save data

$list = tx_div::makeInstance('tx_lib_object');
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
    $entry = new tx_lib_object($row);
    $list->append($entry);
}

So you can use this dataobject in the view.

vg  Steffen 




More information about the TYPO3-team-extension-coordination mailing list