There are mainly two scenarios for highlighting navigation categories: when SSI is enabled and when SSI is disabled. Since SSI is a common block, it can only be dynamically controlled in each template using JavaScript. The following describes these scenarios separately.
After SSI support is enabled, since templates are incorporated into the main template through SSI, there will only be one static page for the templates referenced by multiple pages. Therefore, it’s not possible to use context-related information within these templates. ${Catalog.catalogId} To determine which category the current page belongs to, you can use JavaScript on the page to make this judgment.
Usage scenarios: The content details page is used to determine which top-level category the current content belongs to.
Header Navigation Block Template
<@cms_catalog level="Root" condition="tree_level=1" size="10">
<#list DataList as c>
<a href="${c.link}" class="nav-${Catalog.catalogId}">${c.name}</a>
</#list>
</@cms_catalog>
Content Details Page Template
......
<@cms_include file="header.template.html"></@cms_include>
<script type="text/javascript">
$(".nav-${(Content.catalogAncestors?split(':'))[0]}").addClass("active");
</script>
......
Disabling SSI support means that the templates referenced in the include directive will now generate HTML output, which can be directly used within the current template context. ${Catalog.catalogId} To determine which category the current page belongs to.
Usage scenarios: The content details page is used to determine which top-level category the current content belongs to.
Header Navigation Block Template
<@cms_catalog level="Root" condition="tree_level=1" size="10">
<#list DataList as c>
<a href="${c.link}" class="${((Content.catalogAncestors?split(':'))[0]))==(c.catalogId?string))?then('active','')}">${c.name}</a>
</#list>
</@cms_catalog>
Content Details Page Template
......
<@cms_include file="header.template.html"></@cms_include>
......