Content Types

Version

5.6.0 or newer

Table of contents

The content types allow you to create backend modules that you can use to maintain your own content and, for example, display it in the frontend. It is conceivable, for example, to create a list with different recipes.
In this article we will show you which steps are necessary.
To illustrate this even better, you will find a specific example with corresponding screenshots at the end.

Create a new content type

Before you can create individual pages and fill them with content, it is necessary to define the basic framework for the pages at first.

How to do this manually via the backend is described here.
Furthermore, it is possible to provide a content type via your own plugin - you can find out how this is possible in our developer documentation at https://developers.shopware.com/developers-guide/content-types.

To create a content type, first open the module under Configuration > Content Types and click Add item(1).

 

General Configuration

 



In the General tab you can first enter a name (1) for the content type. This is used in the backend under Contents as a menu entry for the content type. You can use this menu entry later to manage the individual contents. This is described in more detail in the section Edit contents.
The name is also used for the page title in the frontend if you have activated the function Create a Listing/Detail Page in the Frontend (3).
The icon-name (2) defines the icon that is displayed next to the name in the backend menu. A large selection of predefined icons is available, the overview with the name to be entered here can be found at https://developers.shopware.com/designers-guide/backend-icons/

For the visualization you can configure the following points:
First, you determine wether this content type should create a listing/detail page in the frontend (3). If you activate this, you will see an info line below the name in which you can see how to call up the summary. You can then link this entry in a category, for example, to enable your customers to call it up by clicking on this category.

Please note that the initial assigned name is used for the generation of this link.
You can change the name afterwards, but the technical URL (call via shopware.php) keeps the original structure.
However, the SEO URLs are renamed when the SEO index is rebuilt if the corresponding URL is still available.

The table Seo-URLs (4) shows you the generated Seo-URLs, which you can use to view the pages in the frontend. You define the structure of the Seo-URLs via the Seo-URL template (10).
If you activate the display in the frontend, the entries Title (5), Description (6), Image (7), Meta Title (8) and Meta Description (9) are mandatory. Please note that it is necessary first to create corresponding fields in the Fields area (11) in order to be able to make a selection. You can read more about this in the section Configuring Fields

Configuring Fields


To create a field, click on Add new field (1), which opens the following screen.


The label (1) is used to identify the field. It is used in the backend module as a column header (provided Show field as column in backend (6) is active) and in the frontend as a header for the respective block.
You can also define whether this field is required (2).
Type (3) determines which data format is used for the field or what content it can contain.
The (optional) help text (4) is displayed in the backend module by mouseover via a blue question mark symbol next to the field. In addition, a support text (5) can be displayed below the respective field. This text, for example, can provide a short explanation of the field.
Especially with more extensive content, the overview in the respective module can become confusing due to the large number of columns, so it is possible not to show field as column in the backend (6). The content of the field can still be maintained normally, but is not displayed in the backend overview.
It is also possible to exclude the content of a field from the search (7) in the respective content module.
For each field it can be configured whether it is translatable (8). This only concerns the contents of the field. The further translation options are described in the section Translation

After you have created your required fields and made the necessary entries in the General tab, you can save the content type. This will create a new entry in the Contents menu now. The entry may only be correctly visible once you have reloaded the backend.

Edit contents

Each content type created provides its own entry in the Contents menu, which can be used to maintain the individual contents.
 


To create a content, click on the Add item button (1), the mask with the individual fields that you have previously defined when creating the content type will open.
 


After you have filled in the individual fields and saved the window, a corresponding content page will be created.
In the frontend you reach the content overview via the url your-shop.com/name-of-the-content-type, a single content page via your-shop.com/name-of-the-content-type/title-of-content.
We show you in the example below how this looks like in detail.
 

Translation

 

Backend module

If you create a content type and thus a backend module is created, this is initially only available in one language in the backend. To make the names of the fields available for other languages as well, snippets are automatically generated when you create a field. You can then use them to translate the text. The snippets are stored for each content type in a separate subdirectory and you can find them in the snippet administration under Namespaces/backend/custom "nameofmodule".
In addition to the name of the field, you can also change the help and support text here.To translate the entry in the Content menu, the entry CustomNamedesModuls/index is available under backend/index/view/main.

Frontend

field contents
When you create a field for a content type, you can define whether this field can be translated. If you activate this option, the globe symbol will be displayed in the corresponding field, which is also known from other areas in Shopware, and can be used to open the translation module for the field. This makes it possible to create a separate content for each language- or subshop.

Snippets
In the snippet administration, similar to the backend translation, an area for snippets of the content type is created for the frontend. This area also has the name custom"nameofcontenttype" and can be found under Namespace/frontend.
In these snippets you can set things like Meta-Title and Meta-Description.
In addition, you translate the name that is displayed in the frontend on the overview page of the content type. To do this, you need to create another snippet with the name name and define its contents.
Further information on the snippets can be found at https://docs.shopware.com/en/shopware-5-en/settings/snippets

Example

Since settings are made in several places when the content types are used, we would like to explain this with an example.
In this example, a page with recipes is to be created.
The basic module used to create recipes is created and configured via Configuration > Content types. Here you can also specify which data you want to maintain for the recipes and create the corresponding fields.
In the example we use title, description, picture, ingredients and preparation.
After you have done this as described in the section Create a new content type, you can now create the individual recipes. This is possible in the menu Content, here is a new entry with the name of the content type (for example "Recipes") available now. By clicking here you can open the overview of the recipes created and add new recipes. In the window for adding a recipe, you will now see the individual fields that you defined in advance when creating the content type.
The following snippet entries are available for the translations:
backend/index/view/main - CustomRecipes/index for the entry in the Content menu
backend/customrezepte/main contains the snippets for the individual entries within the backend module.
frontend/customrezepte/main provides snippets for adapting meta information in the frontend.

 

Views

Backend
 

Configuration > Content Types

 

Content Types > General
 

Content > Fields

 

Menu Content
 

Content > Recipes

 

Recipes > Details
 

Frontend

Overview
 

Detail view