Global contacts with Mask

Introduction

Some websites show contacts in a sidebar. The contact-persons are often on more than one page. It is not a good idea, to create separate contentelements on each page for the same person. A better way would be to reference the contacts from a centralized unique record per person. The benefit is, that changes (e.g. the telephone number) must be done only on one place.

With Mask it is possible to handle this.

Thank you

This is a sponsored Blogpost from webconsulting business services gmbh. A sponsored Blogpost is one of several ways to support Mask. We need sponsors to make Mask better. If you are interested, please read here or have a look at our Templavoila Converter.

Implementation

Create a folder in the pagetree

At first, create a folder in your pagetree. Name it "Contacts".

Create a Mask contentelement

Of course, you need Mask to be set up on your system. If done, open the backend module of Mask. Create a contentelement with the needed fields for your contact and use suitable fieldtypes for them. The contentelement also needs a name and an element-key.

Create content

Now it's time to create some contact contentelements. Simply switch to the "Page" or "List" module and choose the folder "Contacts". Fill in the fields that are previously created.

Backendlayout

To connect pages with contacts, you need at least one Backendlayout. Switch back to the Mask-Module and edit the choosen Backendlayout. Add a field with the type "Selectbox" to it. We recomment the "Rendertype" "Shuttle" for a comfortable handling.
In the tab "Database", connect the Selectbox with the Contacts: Fill out the field "foreign_table" with "tt_content". To show only contacts, and not all contentelements, fill out the field "foreign_table_where" with "AND CType='mask_content'". Note, that this is the key of the contact-contentelement with the prefix "mask_".

Adjust HTML templates

You have to adjust two HTML files:

The HTML template of the page

Extend the HTML template with the following Fluid-Tag at the place, where you want to show your contacts (e.g. in the sidebar):

 

 <f:cObject typoscriptObjectPath="lib.contact" data="{data.tx_mask_contacts}"/>

 

In the TypoScript Setup field, load the referenced contentelements:

 

lib.contact = RECORDS
lib.contact {
  tables = tt_content
  source.current = 1
  dontCheckPid = 1
}

 

The HTML template of the contact contentelement

This is more design work then technically. Adapt the generated file from Mask, or use the HTML preview from the Mask Backendmodule to find the correct placeholders and Fluid-Tags for the Mask fields.

Allow contacts only in the folder

To avoid editors from adding contact contentelements directly on pages, allow them only in the specified folder. Add this TypoScript to your websites root page-TSconfig:

 

[page["uid"] != 99]
  mod.wizards.newContentElement.wizardItems.mask.show := removeFromList(mask_contact)
  TCEFORM.tt_content.CType.removeItems = mask_contact
[end]

 

The pid 99 in the first line corresponds to the page uid of the folder "contacts".

Add relations

Now it's time for the editor, to create the relations. Open the page properties of any contentpage with the assigned Backend-Layout from above. In the last tab "Content-Fields" you will find the relations.

Last steps

Never forget to include the TypoScript template fluid_styled_content and the TypoScript Template Mask in your root-template, to get content output in the frontend in general.

Be sure, that the editor have access to the contact contentelement and to the page field "contacts".

If there are more than one Backend-Layouts, reassign the field to them, if you need the contacts there too.

Download and further links

Here you can download our working mask_project extension.

If you are interested in more details, follow these links: