Skip to main content
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
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().
The function cannot be used for standard templates from the <Templates> section. However, activation by WEBSALE AG is not required.
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.

ContentControl-SetHeader_Status()

Sets the HTTP status code of the response.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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

The tags at a glance

All tags are only permitted on templates that are stored in the <ContentControlLoadTemplates> section of the shop configuration.
  • Guide: SEO URLs and link optimisation
  • Guide: Embedding external content
  • Guide: JSON interface
  • Reference: <ContentControlLoadTemplates> section