cgoit/contao-persons-bundle

显示contao中常用人员的详细信息

资助包维护!
cgoIT
Ko Fi

安装次数: 1,289

依赖关系: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 0

开放问题: 0

类型:contao-bundle

2.2.0 2024-06-12 07:00 UTC

README

Dynamic JSON Badge CI

通常情况下,个人信息会在网页的多个地方显示。特别挑战的是始终保持前端各个位置的一致性。

借助本模块,可以在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开始,联系信息数据以两种不同的方式在模板中可用

  1. 在模板中,您将访问一个名为contactInfos的数组。该数组为每个联系信息有记录。每个条目本身也是一个数组,包含三个键:typelabelvalue
  2. 每个联系信息在模板中都是可用的。每个人都有如<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(); ?>