首页 文章

从基于Extbase PHP的视图(TYPO3)中的文件引用获取图像路径

提问于
浏览
0

我使用基于PHP的视图在Extbase扩展(TYPO3 6.2)中返回XML . 除了需要包含在XML中的图像路径之外,所有工作都很好 .

我使用以下内容来获取文件引用:

$user->addChild('event_image', $event->getPerformance()->getEventImage());

XML中的输出是:

<event_image>TYPO3\CMS\Extbase\Domain\Model\FileReference:124</event_image>

当我尝试使用此代码获取图像的URL路径时

$user->addChild('event_image', $event->getPerformance()->getEventImage()->getImage()->getOriginalResource()->getPublicUrl());

我收到以下错误消息:

致命错误:调用未定义的方法TYPO3 \ CMS \ Extbase \ Domain \ Model \ FileReference :: getImage()

我的问题:如何从文件引用中获取URL路径?

2 回答

  • 1

    如果您没有使用流体模板,请仔细查看TYPO3安装中的 typo3/sysext/fluid/Classes/ViewHelpers/Uri/ImageViewHelper.php .

    这基本上就是函数调用,就像在XML模板中使用f:uri.image流体Viewhelper一样:

    <event_image><f:uri.image src="{event_image}" treatIdAsReference="1" /></event_image>
    
  • 1

    您的代码中似乎存在拼写错误 . 该方法称为getOriginalResource(),而不是getOriginalRecource() .

相关问题