【发布时间】:2016-12-27 22:37:48
【问题描述】:
所以目前我已经进入了我的控制器:
public function indexAction()
{
$repository = $this->getDoctrine()->getRepository('ApiBundle:Request');
$themes = $repository->findAll();
return $this->render('ApiBundle:Default:index.html.twig', ['themes' => $themes]);
}
在我的树枝上:
{% for theme in themes %}
<div am-col="md-6">
<div am-row>
<div am-col="md-3">
{{ theme.preview|json_encode }}
</div>
<div am-col="md-8">
{{ theme.name }}
</div>
</div>
</div>
{% endfor %}
现在theme.previews 返回一个json,如下所示:
{"icon_with_video_preview":{"icon_url":"https:\/\/0.s3.envato.com\/files\/170231072\/design-wordpress80.png","landscape_url":"https:\/\/0.s3.envato.com\/files\/170231083\/design-wordpresspreview.jpg","video_url":"https:\/\/0.s3.envato.com\/h264-video-previews\/02e0816d-0957-45c4-af2c-792e37bcc37a\/14727479.mp4"}}
我需要访问和显示 icon_url。有任何想法吗? l 目前尝试{{ theme.preview.icon_with_video_preview.icon_url }},但收到错误提示此数组无法转换为字符串。
【问题讨论】:
-
您可能想发布您使用的确切代码、确切错误以及实体的相关部分。