Templates 如何显示创建配置文件的用户名(配置文件的所有者)?
我有一个Drupal8网站,我想定制我的页面模板 我使用模块:Templates 如何显示创建配置文件的用户名(配置文件的所有者)?,templates,drupal,twig,Templates,Drupal,Twig,我有一个Drupal8网站,我想定制我的页面模板 我使用模块: “个人资料” 以下是自定义配置文件页面的模板: {# /** * @file * * Default theme implementation for profiles. * * Available variables: * - content: Items for the content of the profile. * Use 'content' to print them all, or print a
- “个人资料”
{#
/**
* @file
*
* Default theme implementation for profiles.
*
* Available variables:
* - content: Items for the content of the profile.
* Use 'content' to print them all, or print a subset such as
* 'content.title'. Use the following code to exclude the
* printing of a given child element:
* @code
* {{ content|without('title') }}
* @endcode
* - attributes: HTML attributes for the wrapper.
* - profile: The profile object.
* - url: The profile URL, if available.
*
* @ingroup themeable
*/
#}
<div{{ attributes.addClass('profile--personnel--teaser') }}>
<div class="views-row">
<h3 class="views-teaser-title">
{{ ??? USERNAME ??? }}
</h3>
</div>
</div>
{#
/**
*@file
*
*配置文件的默认主题实现。
*
*可用变量:
*-内容:配置文件内容的项目。
*使用“内容”打印所有内容,或打印一个子集,如
*“content.title”。使用以下代码排除
*打印给定子元素:
*@code
*{{内容|无('title')}
*@endcode
*-属性:包装器的HTML属性。
*-profile:配置文件对象。
*-url:配置文件url(如果可用)。
*
*@ingroup主题表
*/
#}
{{???用户名???}
如何显示创建配置文件的用户名(配置文件的所有者)?您可以从
profile
获取所有者对象。它是该页面中可用的变量。可以使用kint查看该变量
{{kint(profile.getOwner())}}
从中你可以得到姓名、邮件等。。所有者
{{ profile.getOwner().name.value }}
{{ profile.getOwner().mail.value }}