LoginSignup
0
0

More than 5 years have passed since last update.

eZ Publish 5.x テンプレート関連

Posted at

ビューパラメーターの取得

{{ app.request.attributes.get( 'viewParameters' ).offset }}

コンテンツ名

{{ content.contentInfo.name }}

フィールドタイプの取得

{{ content.getField( 'url' ).value.link }}

フィールドタイプのレンダリング

{{ ez_render_field( <content>, <field_name>, {
            'template': 'eZDemoBundle:fields:fields.html.twig',
            'lang': 'eng-GB'
            } ) }}

画像のレンダリング

<img src="{{ asset( ez_image_alias( <field>, <versionInfo>, <parameter_alias> ).uri ) }}" alt="{{  <field>.value.alternativeText }}">
or

{{ ez_render_field(content, 'image', { 
                                        parameters:{ alias:'small' },
                                        attr:{ class:'maClasse', custom_attribute:'value' }
                                     }
                  )
}}

妥当なファイル名での ezbinaryfile ダウンロードリンクのレンダリング

<a href="{{ path( 'ez_legacy', { 'module_uri': 'content/download/' ~
                                               <content>.contentInfo.id ~ '/' ~
                                               <field>.id ~
                                               '/version/' ~ <content>.contentInfo.currentVersionNo ~
                                               "/file/" ~ <field>.value.fileName|escape( 'url' ) }
         ) }}"/>
{{ <field>.value.fileName }}
</a>

"ESI" でのコンテンツタイプのレンダリング

 {{ render( controller( "ez_content:viewLocation", { "locationId": 123, "viewType": "line" }, {"strategy": "esi"} )) }}

=> ez_content : service definied in service.yml

=> To use Varnish, don't forget to remove EzPublishCache from index.php

非同期メソッドでのコンテンツタイプのレンダリング

 {{ render( controller( "ez_content:viewLocation", { "locationId": 123, "viewType": "line" }, {"strategy": "hinclude"} )) }}

=> Don't forget to add hinclude.js (http://mnot.github.io/hinclude/)

viewbaseLayout の拡張

{% extends viewbaseLayout %}

=> eZ/Bundle/EzPublishCoreBundle/Resources/views/viewbase_layout.html.twig

レガシー module/view への URL

{{ path( 'ez_legacy', { 'module_uri': 'my_modyle/my_view/(param1)/value1' } ) }}

コンテンツへのリンク

相対パス

{{ path( 'ez_urlalias', {'locationId': content.contentInfo.mainLocationId} ) }}
or
{{ path( location_object ) }}

絶対パス

{{ url( 'ez_urlalias', {'locationId': content.contentInfo.mainLocationId} ) }}
or
{{ url( location_object ) }}

ユーザーが認証されているかどうかを確認する方法

{% if app.security.token.authenticated %}
...
{% else %}
...
{% endif %}

Twig ヘルパー

ezpublish.siteaccess
ezpublish.requestedUriString
ezpublish.systemUriString
ezpublish.viewParameters
ezpublish.viewParametersString
ezpublish.siteName
ezpublish.legacy

レガシー関連

ezpublish.legacy.all
ezpublish.legacy.keys
ezpublish.legacy.get
ezpublish.legacy.has

レガシーテンプレートのインクルード

{% include "design:my/old_template.tpl" with {"someVar": "someValue"} %}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0