1)cms
2)cms_translations
cms
id
url
status
cms_translations
object_id
title
lang_id
我编写了cmsRepository文件
$q = $em->createQuery("SELECT c , d FROM Dashboard\CmsBundle\Entity\Cms c
JOIN c.translations d
WITH c.id = d.object AND c.status = 1
GROUP BY c.sortOrder
ORDER BY c.sortOrder ASC "
);
和index.html.twing文件
{% for entity in enitity_cms %}
<a href="{{ path('_cmsAboutUs' , { slug : entity.url }) }}" >{{ entity.Title }}</a>
{% endfor %}
not print in {{ entity.Title }}
如何在第二个表格的html文件中打印值。
答案 0 :(得分:1)
试试这个
{{entity.translations [0] .Title}}
答案 1 :(得分:0)
要打印第二个值:
{{ entity.translations.title }}
在你的例子中:
{% for entity in entity_cms %}
<a href="{{ path('_cmsAboutUs' , { slug : entity.url }) }}" >{{ entity.translations.title }}</a>
{% endfor %}
我希望这可以帮到你