Custom blocks, like content blocks and contact blocks, are configurable through theme settings. You can control both the content of the blocks as well as their look-and-feel and layout.
Blocks
Presenting categories in blocks or cards is a popular choice, particularly on the Home page.
Cards
Tiles
Lists and list groups
By default custom blocks are displayed on the Home page, however you can use them anywhere in the help center.
You can display custom blocks on the Home page using theme settings.
The following settings, found within the Custom blocks setting group, are available in the to use in every theme when customizing custom blocks:
Setting | Description |
---|---|
Custom blocks style | The style of custom blocks to display. |
Custom blocks color | The color palette used for custom blocks. |
Custom blocks background color | The background color applied to the custom blocks section. |
Custom blocks heading | The heading to display above the custom blocks. |
Custom blocks number | The maximum number of custom blocks to display. |
Custom blocks columns | The maximum number of columns to display per row. |
Custom blocks alignment | The alignment of content within custom blocks. |
Custom blocks image height | The height (in px) for custom block images. |
Select a style from the Custom blocks style setting to have the custom blocks appear.
To display custom blocks on any page in the help center other than the Home page:
-
Select the “Custom template” option from the Custom blocks style setting in the Custom blocks setting group to ensure that there’s not a conflict with an existing micro-template.
-
Copy the HTML hook below into the position where you’d like the custom blocks to appear.
<div class="custom bg-custom-blocks" id="custom-blocks"> <script type="text/javascript"> document.addEventListener('DOMContentLoaded', () => { Util.renderTemplate(document.getElementById('custom-blocks'), 'custom-blocks', Theme.customBlocks); }) </script> </div>
-
Copy-and-paste your selected pattern micro-template into the bottom of the
footer.hbs
template.
The title, description, URL and image of each block is configurable through theme settings.
Custom actions
Using custom JavaScript on the page, it’s possible to have certain URLs (like those starting with a hash tag) trigger actions.
For example, if you wanted the Web Widget to be hidden by default and then revealed when a user clicks on the Chat with us block, you could configure the block’s URL to be #show-widget
and then add something like the following custom JavaScript code to the Home page template (home_page.hbs
):
<script type="text/javascript">
// Shows the Zendesk Web Widget
function showWebWidget(e) {
zE('webWidget', 'show');
zE('webWidget', 'open');
e.preventDefault();
}
document.addEventListener("DOMContentLoaded", function() {
// Hide the Zendesk Web Widget on page load
zE('webWidget', 'hide');
// Add the required event listeners
var links = Array.prototype.slice.call(document.querySelectorAll('a[href="#show-widget"]'));
links.forEach(function(a) {
a.addEventListener('click', showWebWidget, false);
});
});
</script>