It often happens that information about people is displayed in many places on a web page. The particular challenge is to keep the individual places in the frontend consistent at all times.
With the help of this module, such people can be managed centrally in the backend of Contao in a clear list. The data from this list can then be easily used and displayed in different places in the frontend.
composer require cgoit/contao-persons-bundle
Starting with version 3.0.0 this extension uses TWIG templates instead of the deprecated html5 templates. You can still customize your templates. In the following table you can find an overview how the old templates map to the new ones.
old HTML5 template | new TWIG template | |
---|---|---|
Content Element to display a list of persons | ce_person.html | content_element/persons.html.twig |
Frontend module to display a list of persons | mod_person.html5 | frontend_module/persons.html.twig |
Template for one person | person.html5 | component/person.html.twig |
Since version 2.1.0 you can configure the contact information types via the standard mechanism. To do so
just add your configuration to the config/config.yml
file.
The bundle ships with the following default configuration:
cgoit_persons:
contact_types:
email:
schema_org_type: email
phone:
schema_org_type: telephone
mobile:
schema_org_type: telephone
website:
schema_org_type: url
If you want to add a new contact information type (e.g. fax
) you'll have to configure the following:
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
By adding the label
key to any existing contact_type
you can overwrite the default translation (coming from $GLOBALS['TL_LANG']['tl_person']['contactInformation_type_options']['<type name>']
).
Since version 2.1.0 the contact information data is available in the template in two different ways:
- In the template you'll have access to an array
contactInfos
. This array has entries for each contact information. Each entry is itself an array with three keys:type
,label
andvalue
. - Each contact information is available in the template. Each person has properties like
<type>
(e.g.email
) and<type>_label
(e.g.email_label
).
Since version 2.1.0 you can add schema.org data to your templates like this:
<?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(); ?>