> ## Documentation Index
> Fetch the complete documentation index at: https://dokumentation.websale.de/llms.txt
> Use this file to discover all available pages before exploring further.

# ContentControl- (Redirect concept for content from third-party systems)

> The tags with which a template sets its own HTTP status code, location and content type, and suppresses or replaces the response body.

If content from a third-party system is loaded into the shop, for example via an external include or the JSON interface, and this content no longer exists, the shop still delivers the status code 200. From its point of view, rightly so: the template on which the external content is embedded does exist.

For search engines, this is a problem. They are told about a working page on which nothing is left. With ContentControl, a template can correct this decision afterwards and deliver a 404 or a redirect instead.

The tags with the prefix `ContentControl-` intervene in the HTTP header for this purpose.

Guide: SEO URLs, section Redirect concept for content from third-party systems

> [!WARNING]
>
> This refers to the HTTP header, i.e. the protocol between server and browser. It is not the `head` section of the HTML document. If you change something here, you change the server's response and not the page content.

## The prerequisite

These tags do not work on just any template. The template must be entered in the shop configuration `shop.config` in the `<ContentControlLoadTemplates>` section and called via `WS-LoadTpl()` or `WS-SSLLoadTpl()`.

```text theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
<ContentControlLoadTemplates>
   +Entry = tpl_cms.htm
</ContentControlLoadTemplates>
```

> [!WARNING]
>
> The function cannot be used for standard templates from the `<Templates>` section. However, activation by WEBSALE AG is not required.

> [!NOTE]
>
> Use `ST-ContentControl` to check whether the function applies at all at the point where you are. Wrap the entire block in it; then it remains ineffective on a wrong template instead of faulty.

## The complete example

A piece of content from the third-party system has disappeared, and the page should respond with its own 404 document.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{ST-ContentControl}
   ~ContentControl-SetHeader_Status(404)~

   <WS-ContentControl-UseAsExclusiveResponseBody>
   <html>
      <head><title>Seite nicht gefunden</title></head>
      <body>
         <h1>Diese Seite gibt es nicht mehr.</h1>
      </body>
   </html>
   </WS-ContentControl-UseAsExclusiveResponseBody>
{/ST-ContentControl}
```

## ContentControl-SetHeader\_Status()

Sets the HTTP status code of the response.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
~ContentControl-SetHeader_Status(404)~
~ContentControl-SetHeader_Status(301)~
```

> [!WARNING]
>
> The shop removes **all spaces** from the parameter. A written-out status message therefore does not arrive unchanged: `404 Not Found` becomes `404NotFound`. Only specify the number as long as this has not been clarified.

> [!NOTE]
>
> The tag is a single tag only and supports tag-in-tag. The status code can therefore come from another tag.

## ContentControl-SetHeader\_Location()

Sets the target address of the redirect. Together with a status code from the 300 range, this results in a complete redirect.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
~ContentControl-SetHeader_Status(301)~
~ContentControl-SetHeader_Location(https://www.ihr-shop.example/neue-seite)~
~ContentControl-SuppressResponseBody~
```

> [!NOTE]
>
> A redirect does not need any content. Therefore, suppress the response body with `ContentControl-SuppressResponseBody`; otherwise, the shop also sends the parsed template.

### Getting the target address from another tag

If the target address itself needs to be calculated first, `DC-WSTagParameter-prepare` provides the result of a tag as a parameter for another tag.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{DC-WSTagParameter-prepare}
   ~PR-Link(12345)~
{/DC-WSTagParameter-prepare}

~ContentControl-SetHeader_Location($DC-WSTagParameter-use$)~
```

Reference: DC-WSTagParameter-prepare

## ContentControl-SetContentType()

Sets the content type of the response. Without this tag, the shop sends `text/html` with the configured character set.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
~ContentControl-SetContentType(application/json; charset=utf-8)~
```

> [!NOTE]
>
> This tag is not described in the previous documentation, but it exists in the shop. It is useful when a template should not deliver HTML but, for example, JSON or XML.

> [!WARNING]
>
> Here, too, the shop removes all spaces from the parameter. A content type with an additional specification therefore arrives without spaces. Check the result before you rely on it.

## ContentControl-SuppressResponseBody

Suppresses the response body. The shop then only delivers the headers.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
~ContentControl-SuppressResponseBody~
```

> [!NOTE]
>
> The tag can also be used as an area tag and then applies if ContentControl is active on this page at all. However, the content is only suppressed by the single tag. The area tag alone has no effect.

> [!WARNING]
>
> Suppression beats replacement. If `~ContentControl-SuppressResponseBody~` is on the page, content set with `WS-ContentControl-UseAsExclusiveResponseBody` is no longer delivered. Use one or the other.

## Replacing the response body

If your own content should be delivered instead of the parsed template, wrap it in a pair of markers.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
<WS-ContentControl-UseAsExclusiveResponseBody>
   ...
</WS-ContentControl-UseAsExclusiveResponseBody>
```

> [!NOTE]
>
> This is not a tag in the usual sense and is therefore not written in curly braces. The shop searches the fully parsed page for this pair of markers and cuts out everything in between. Exactly this excerpt becomes the response; everything before and after it is dropped.

> [!WARNING]
>
> The pair of markers must be written exactly like this, opening and closing. If one of the two is missing, the shop does not find the excerpt and delivers the whole page.

## The order in the response

The shop sets the headers in a fixed order: first the content type, then the cookies, then the status, then the location, then the file name if applicable, and finally the content.

> [!NOTE]
>
> The order in the template does not matter. You can set the status before or after the location; the result is the same. The only important thing is that the tags are on the template before it is delivered.

## Tags of other prefixes

| Tag | Purpose | Prefix |
| - | - | - |
| `ST-ContentControl` | checks whether ContentControl is available at this point | ST- |
| `WS-ContentControl-UseAsExclusiveResponseBody` | pair of markers for your own response body | WS- |
| `DC-WSTagParameter-prepare` | prepares a tag result as a parameter | DC- |

## The tags at a glance

| Tag | Single tag | Area tag | Negative area tag | Loop tag |
| - | - | - | - | - |
| `ContentControl-SetHeader_Status()` | yes | – | – | – |
| `ContentControl-SetHeader_Location()` | yes | – | – | – |
| `ContentControl-SetContentType()` | yes | – | – | – |
| `ContentControl-SuppressResponseBody` | yes | yes | yes | – |

All tags are only permitted on templates that are stored in the `<ContentControlLoadTemplates>` section of the shop configuration.

## Related topics

* Guide: SEO URLs and link optimisation
* Guide: Embedding external content
* Guide: JSON interface
* Reference: `<ContentControlLoadTemplates>` section


## Related topics

- [DC- (comparisons and other tags)](https://dokumentation.websale.de/en/v8s/referenz/tags/dc/vergleiche.md)
- [SEO URLs and link optimization](https://dokumentation.websale.de/en/v8s/seo/seo-urls-und-link-optimierung.md)
- [Basics and technology](https://dokumentation.websale.de/en/v8s/referenz/konfigurationen/shopkonfiguration-shop-config/grundlagen-und-technik.md)
- [Integrating external content](https://dokumentation.websale.de/en/v8s/externe-dienste/externe-inhalte-einbinden.md)
- [Exchanging data with external systems](https://dokumentation.websale.de/en/v8s/externe-dienste/daten-mit-externen-systemen-austauschen.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.