We are running data center version of the confluence.
We have a requirement where we have to show subspace navigation element only in specific spaces.
- To do this we have tagged those spaces with "Subspace" category. We should be showing SubSpace navigation to only on these spaces and hide for the rest of them.
Following is the way I have achieved this
- Created piece of velocity code in Look and feel -> Layouts -> Main Layout
<div id="categoryKeyInfo">
#if ($sitemeshPage.getProperty("page.spacekey"))
$action.labelManager.getTeamLabelsForSpace($sitemeshPage.getProperty("page.spacekey"))
#end
</div>The purpose of above code is to get the category information from the current space. As per the documentation and my testing getTeamLabelsForSpace gives us the categories of the space.
- Next I have included Look and feel -> "custom HTML" code "At end of the BODY"
<script>
document.addEventListener('DOMContentLoaded', function(){
//alert(document.querySelector("#categoryKeyInfo").innerHTML) if(!document.querySelector("#categoryKeyInfo").innerHTML.includes("Subspace")){
var subSpaceBar=document.querySelector("#navigationbarpro");
subSpaceBar.style.display="none";
}
}, false);
</script>This above code finds if the space has category as "Subspace" and shows the SubSpace app navigation or it will hide it.
This approach is working but wanted to make sure that this is the right way to achieve this. Is there any better way to do this? Please let me know.