[Contao 3.3 RC1] Can't take calendar event's image teaser in templates #7001

Closed
rocchidavide opened this Issue May 14, 2014 · 3 comments

Projects

None yet

2 participants

@rocchidavide

I need image teaser in cal_default.html5 for each event listed. A print_r() of $event says that.

[addImage] => 1
[singleSRC] => ��Y!~���9�� ��
[alt] => 
[size] => a:3:{i:0;s:0:"";i:1;s:0:"";i:2;s:12:"proportional";}
[imagemargin] => a:5:{s:6:"bottom";s:0:"";s:4:"left";s:0:"";s:5:"right";s:0:"";s:3:"top";s:0:"";s:4:"unit";s:0:"";}
[imageUrl] => 
[fullsize] => 
[caption] => 

So, imageUrl is empty. How can I obtain the image url?

@leofeyer leofeyer added this to the 3.3.0 milestone May 14, 2014
@leofeyer leofeyer added invalid and removed defect core labels May 19, 2014
@leofeyer leofeyer removed this from the 3.3.0 milestone May 19, 2014
@leofeyer
Member

I think you are jumbling things up here. The imageUrl parameter refers to the "Image link target" field. It does not store the file path; you have to use the FileModel class to obtain it.

@leofeyer leofeyer closed this May 19, 2014
@rocchidavide

In system/modules/calendar/classes/Calendar.php, I see this code (from line 439):

    // Add the article image as enclosure
    if ($objEvent->addImage)
    {
        $objFile = \FilesModel::findByUuid($objEvent->singleSRC);

        if ($objFile !== null)
        {
            $arrEvent['enclosure'][] = $objFile->path;
        }
    }

If I have understood right, I should find the image path in $event['enclosure'] (in my cal_default.html5 template). But this key is empty.
Is this the usage of FilesModel that you referred?
Thank you

@rocchidavide

Trying to do this:

<?php
  print_r(\FilesModel::findByUuid($event['singleSRC'])->path);
?>

inside cal_default.html5, I can finally obtain the file path :)

So now my questions are:

  1. is the correct mode to proceed?
  2. can this feature be added to the core? I mean, having image path directly in a key of $event
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment