1

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 }}   

2番目のテーブルからhtmlファイルに値を出力するにはどうすればよいですか。

4

2 に答える 2

1

これを試して

{{エンティティ.translations[0].タイトル}}

于 2013-10-09T13:34:17.810 に答える
0

2 番目の値を出力するには:

{{ entity.translations.title }}

あなたの例では:

{% for entity in entity_cms %}
    <a href="{{ path('_cmsAboutUs' , { slug : entity.url }) }}" >{{ entity.translations.title }}</a>
{% endfor %}    

これがお役に立てば幸いです

于 2013-09-30T12:49:12.333 に答える