Applying a modified content type template
You can apply a modified content type template to override a default content type template in the Developer Portal. For example, you can override the product content type template to change its layout.
Before you begin
You must have administrator access to complete this task.
You must also have a custom sub-theme, and a copy of an existing template that you want to update. For information about how to create a sub-theme, see Creating a sub-theme.
About this task
- html.html.twig - the template for Developer Portal HTML pages
- page.html.twig - the body of Developer Portal HTML page
- node.html.twig - the template for all of the content nodes
- comment.html.twig - the template for all of the comment nodes
- search-result.html.twig - the template for search results
- node--product.html.twig - the template for nodes that use the Product content type
- node--product--teaser.html.twig - the template for the previews for the Product content type
Modifying Twig templates allows very fine-grained control over the structure of pages. However, it also means you might miss new features and defect fixes that are made to the original templates, as your Developer Portal is using your overrides instead of the originals. So, if you override a template, it is your responsibility to check the templates in the latest API Connect releases, and to ensure that any equivalent changes that are needed to your overrides to maintain functional equivalence are made.
Directly editing any API Connect theme files is not permitted or supported, as edited versions of these files are overwritten when a fix pack or iFix is installed.
To override a default content type template:
Apply the modifications that you require to the default template that you obtained.
Warning: Although the ability to override templates is supported, if you override a template they are your responsibility. Templates can be from multiple sources and compatibility with an earlier version is not ensured. You must check the templates in the latest API Connect release to check whether you need to make equivalent changes to your overrides to maintain functional equivalence.
- Create a directory in your custom sub-theme, and name it templates.
Add your modified template to the templates directory.
Note: The modified template file name must be identical to the original name of the template file that it is overriding.
- Log in to the Developer Portal UI as an administrator.
- If the administrator dashboard is not displayed, click Manage to display it.
- Install your custom sub-theme onto the Developer Portal by clicking on the administrator dashboard.
- Click Choose file, select your sub-theme, and then click Install.
Click Install newly added theme, find your new theme in the list of Uninstalled themes, and click Install and set as default to set your new custom sub-theme as the default theme for your site.
Your new theme, which contains the modified template file, is now set as the default theme, and is listed in the Installed themes section.