cgoit / contao-persons-bundle
显示contao中常用人员的详细信息
2.2.0
2024-06-12 07:00 UTC
Requires
- php: ^8.1 || ^8.2 || ^8.3
- codefog/contao-haste: ^5.1
- codefog/tags-bundle: ^3.3
- contao/core-bundle: ^5.3
- doctrine/dbal: ^3.3
- mvo/contao-group-widget: ^1.5
- symfony/config: ^6.1
- symfony/dependency-injection: ^6.1
- symfony/event-dispatcher: ^6.1
- symfony/http-foundation: ^6.1
- symfony/http-kernel: ^6.1
Requires (Dev)
- contao/manager-plugin: ^2.0
- phpunit/phpunit: ^10.3
- symfony/phpunit-bridge: ^7.0
- terminal42/contao-build-tools: dev-main
Conflicts
- contao/manager-plugin: <2.0 || >=3.0
README
通常情况下,个人信息会在网页的多个地方显示。特别挑战的是始终保持前端各个位置的一致性。
借助本模块,可以在Contao后端以清晰的列表集中管理这些人员。然后,可以轻松地在前端的不同位置使用和显示这些列表中的数据。
安装
composer require cgoit/contao-persons-bundle
配置
从版本2.1.0开始,您可以通过标准机制配置联系信息类型。为此,只需将您的配置添加到config/config.yml
文件中。
该捆绑包附带以下默认配置
cgoit_persons: contact_types: email: schema_org_type: email phone: schema_org_type: telephone mobile: schema_org_type: telephone website: schema_org_type: url
如果您想添加新的联系信息类型(例如传真
),您需要配置以下内容
cgoit_persons: contact_types: email: schema_org_type: email phone: schema_org_type: telephone mobile: schema_org_type: telephone website: schema_org_type: url fax: schema_org_type: faxNumber label: de: Fax en: Facsimile
通过向任何现有的contact_type
添加label
键,可以覆盖默认翻译(来自$GLOBALS['TL_LANG']['tl_person']['contactInformation_type_options']['<type name>']
)。
模板数据
从版本2.1.0开始,联系信息数据以两种不同的方式在模板中可用
- 在模板中,您将访问一个名为
contactInfos
的数组。该数组为每个联系信息有记录。每个条目本身也是一个数组,包含三个键:type
、label
和value
。 - 每个联系信息在模板中都是可用的。每个人都有如
<type>
(例如email
)和<type>_label
(例如email_label
)这样的属性。
schema.org数据
从版本2.1.0开始,您可以将schema.org数据添加到模板中,如下所示
<?php $this->extend('block_searchable'); ?> <?php $this->block('content'); ?> <div class="persons"> <?php foreach ($this->persons as $person): ?> <?php $this->insert($person->personTpl, $person->arrData); ?> <!-- add schema.org data --> <?php $this->addSchemaOrg($this->getSchemaOrgData($person)); ?> <?php endforeach; ?> </div> <?php $this->endblock(); ?>