Discussion:
[TYPO3-english] fluid: Objects lost in for ech
Christian Tauscher
2018-08-07 09:49:37 UTC
Permalink
Hi dear developers.

Even it became a quiet place here I give it a try:

I habe an extbase Extention written.
in my view i do this:

//the model is a name, uid, wahtever... and a >image<!

$singleObject = $this->getOneSpecialRecordFromDB();
$moreObjects = $this->getAllFromDB();
$this->view->assign('theSingleData', $singleObject);
$this->view->assign('theMultipleData', $moreObjects);

OK so far. Lets have a look inside fluid:

for theSingleData f:debug gives me this for the image:

image => TYPO3\CMS\Extbase\Domain\Model\FileReferenceprototypepersistent
entity (uid=17069, pid=341)

perfekt! i can render the image with f:image as easy as all the other
fields.

since 'theMultipleData' is a array of 1or more of these Objects I use a
loop:

<f:for each="{theMultipleData}" as="item">
<f:debug>{item}</f:debug>
</f:for>

it loops throug the array as expected, giving me fluid accessible names,
uids end everything, but

image => 1

Where has my Image gone to? image=>1 means there is ONE image, but the
Object is lost!?!?


Can you help me understanding/solving this?

Thank you!


Christan.
Christian Platt
2018-08-08 04:42:52 UTC
Permalink
Hi Christian,


in the listView /multipleView: do you use an array as a result of database or an array given from database?

so what does <f:debug>{item.image}</f:debug> in listView say?


Christian
Post by Christian Tauscher
Hi dear developers.
I habe an extbase Extention written.
//the model is a name, uid, wahtever... and a >image<!
$singleObject = $this->getOneSpecialRecordFromDB();
$moreObjects = $this->getAllFromDB();
$this->view->assign('theSingleData', $singleObject);
$this->view->assign('theMultipleData', $moreObjects);
image => TYPO3\CMS\Extbase\Domain\Model\FileReferenceprototypepersistent
entity (uid=17069, pid=341)
perfekt! i can render the image with f:image as easy as all the other
fields.
since 'theMultipleData' is a array of 1or more of these Objects I use a
<f:for each="{theMultipleData}" as="item">
<f:debug>{item}</f:debug>
</f:for>
it loops throug the array as expected, giving me fluid accessible names,
uids end everything, but
image => 1
Where has my Image gone to? image=>1 means there is ONE image, but the
Object is lost!?!?
Can you help me understanding/solving this?
Thank you!
Christan.
_______________________________________________
TYPO3-english mailing list
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
Christian Tauscher
2018-08-08 07:38:22 UTC
Permalink
Post by Christian Platt
in the listView /multipleView: do you use an array as a result of
database or an array given from database?
Post by Christian Platt
so what does <f:debug>{item.image}</f:debug> in listView say?
if i make <f:debug>{theMultipleData}</f:debug> it gives me an Array.

The loop i self works correct, the items are rendered, only the
image-field lost its class-reference, thus it cant be rendered.

Strange? Jepp, it is! I never heard about this bevore....


I you ore someone else has an idea: let me know, please"!


Thank you so far,

Christian
Christian Tauscher
2018-08-08 08:00:04 UTC
Permalink
Post by Christian Platt
in the listView /multipleView: do you use an array as a result of database or an array given from database?
// get one record, image render OK
$this->view->assign('singleObject',
$this->objectRepository->findBySpecialCase());

// get all record, fails image rendering :-(
$moreObjects = $this->objetcRepository->findAll();
$this->view->assign('moreObjects', $moreObjects);

The model ist the same, the repository does only a more specific select,
so only ONE record is returned. All methods pass back the same object-type
/**
* ...params...
* @return Tx_Extbase_Persistence_QueryResultInterface
*/
php/fluid debug gives me no hint why single passes on image-object and
list does not....



Christian.
Christian Platt
2018-08-09 06:58:34 UTC
Permalink
so ok,

if you getYour result by findAll you get it then as object and it is also treated as these in the helpviewer...

so what if you do the following
 in list view

<f:for each=„{multiple}" as=„single">

<f:for each=„{single.images}" as=„image">
<p>{image.originalResource.originalFile.title}</p>
</f:for>
</f:for>


or as image
<f:image src=„{single.image.originalResource.originalFile.uid}" alt="" />

also look here
https://docs.typo3.org/typo3cms/ExtbaseGuide/Fluid/ViewHelper/Image.html <https://docs.typo3.org/typo3cms/ExtbaseGuide/Fluid/ViewHelper/Image.html>

What does the f:debug say wuth that. or the output?
Post by Christian Tauscher
Post by Christian Platt
in the listView /multipleView: do you use an array as a result of database or an array given from database?
// get one record, image render OK
$this->view->assign('singleObject',
$this->objectRepository->findBySpecialCase());
// get all record, fails image rendering :-(
$moreObjects = $this->objetcRepository->findAll();
$this->view->assign('moreObjects', $moreObjects);
The model ist the same, the repository does only a more specific select,
so only ONE record is returned. All methods pass back the same object-type
/**
* ...params...
*/
php/fluid debug gives me no hint why single passes on image-object and
list does not....
Christian.
_______________________________________________
TYPO3-english mailing list
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
Loading...