[TYPO3-ect] Copying data from the model to teh view....
R. van Twisk
typo3 at rvt.dds.nl
Sun Mar 4 05:12:06 CET 2007
Steve Ryan wrote:
> Hi Ries,
> in your controller
> $view->set('model',$mymodel);
>
> in your template
> <?php
> $model=$this->get('model');
> ?>
> hi <?= $model->get('name');?>
>
> BTW, Relationship support is moving onwards
> http://svn.syntithenai.com/svn/trunk/t3ext/lib
> http://svn.syntithenai.com/svn/trunk/t3ext/div
> http://svn.syntithenai.com/svn/trunk/t3ext/partnerpersistencedemo
>
> sorry to go out side t3extdev but my host is easy for the moment.
>
> Working on MM as we speak.
>
> cheers
> Steve Ryan
>
hey Steve,
I don't use phpView, but instead I use smarty.
So basically I don't want to interact with the view (lib_object)
but I prefer to operate directly on the dataset.
I don't think I can do this easily in smarty:
{section name=loop value=$model->get('dataSetArray')}
....<how to get the row for each loop to show the data????>
{/section}
Normally I would do this:
{section name=loop value=$dataSetArray}
{$dataSetArray[loop].name}<br />
{$dataSetArray[loop].image}<br />
{$dataSetArray[loop].otherVar}<br />
{/section}
I currently avoid that by assigning the data directory using set,
completely 'bypassing' lib_object. I need to read about SPL I think
to understand if I can use something like that in smarty.
What I can do is create an array of object and loop over that if I want...
Ries
>
>
>
> R. van Twisk wrote:
>
>> 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
>>
>>
>>
--
Ries van Twisk
Freelance Typo3 Developer
=== Private:
email: ries at vantwisk.nl
web: http://www.rvantwisk.nl/freelance-typo3.html
skype: callto://r.vantwisk
=== Work:
email: ries at livetravelguides.com
web: http://www.livetravelguides.com
More information about the TYPO3-team-extension-coordination
mailing list