Frequent Advisor

How to hide the content of a certain blog for the anonymous users?

The idea is to hide the content of a certain blog for the anonymous users. The blog title (link) should be still visible to them from the main page. But when they will try to go inside the blog, they should see no blog content but only "please register" message with the registration link.


Thank you!

9 Replies 9
Honored Contributor


It would require the customization. I think you want something like this(pop will be displayed for logged out user)

Give kudos if you find my posts helpful or mark solution if it answers your query


In order to achieve this, you need to add a different class (for e.g. 'secured-content') to that particular content which you wish to hide from logged out users.

This can be achieved using CSS or Jquery, e.g. :


<#if user.anonymous>
  .secured-content {
     display: none;


Frequent Advisor

Thanks, @VikasB ! It looks like exactly the thing I need. Can you share with me the code or give me the direction to how to create such kind of custom component?

Honored Contributor


You need to put these script in the page header. 
Here is the script to get the page id. You just need to pass the restricted blog id

<#assign restrictedAccess   = false >
<#assign currentUrl         =  coreNode.webUi.url >
<#assign redictionUrl       = webUi.getUserLoginPageUrl(currentUrl) >
<#assign referrerUrl        = http.request.referrer!coreNode.webUi.url >

<#function isRestrictedCat currentNodeList restrictedNode >
    <#list restrictedNode as node>
        <#if currentNodeList?seq_contains(node)>
            <#return true>
    <#return false>
<#assign checkID = 'BlogID'>
<#assign checkIDArray = ["Platforms","UnlimitedProfDev"] >

  <#assign restrictedNodeList = [] >
  <#list coreNode.ancestors?reverse as ansc >
     <#assign restrictedNodeList = restrictedNodeList + []  >
  <#assign restrictedNodeList = restrictedNodeList + []  >
  <#if isRestrictedCat(restrictedNodeList , checkIDArray) && user.anonymous >
    <#assign restrictedAccess  = true >


Here is another script which will run on document ready and will get the values from above script. 

        var restrictedAccess    = ${restrictedAccess?string};
        var currentPageUrl      = '${currentUrl}';
        var referrerPageUrl     = '${referrerUrl}';
        var baseUrl             = window.location.origin;
            }, 700);
            if(currentPageUrl != referrerPageUrl){
                window.location = referrerPageUrl;
                window.location = baseUrl;
Give kudos if you find my posts helpful or mark solution if it answers your query
Frequent Advisor

Thanks @VikasB , your example helped me a lot Robot Happy

Frequent Advisor

@VikasBSo I should make the custom component (#premiumModal in your example) and after that put both code snippets (Freemarker with the restricted Blog ID and JS with the modal component name) in the community wrapper (header) to get your solution work for my case?

Frequent Advisor

Hi @VikasB,
I am still trying to implement your solution but have no luck with that for now. Could you please share the whole custom component code, including the modal html/css?

Should I make the custom component and put inside all the parts together: freemarker script, JS code and the modal HTML/CSS in the following sequence?

1. Freemarker script

2. JS code

3. Modal's HTML/CSS

Or should I put some of these in the community header (wrapper)?

Thank you!

Honored Contributor


All the code snippets(JS, Freemarker, HTML) are on the same page so order does not make any difference.  It would not be possible to share the whole component code but I can help you to figure out the issue. 

  1. Create a custom component and add code to it. 
  2. Add it to the standard header component on studio Page tab so it can work on all the pages.


Give kudos if you find my posts helpful or mark solution if it answers your query
Frequent Advisor


Thanks, @VikasB

The code snippet you provided requires Bootstrap, right?

Unfortunately, due to the technical issues with our legacy custom skin code, I can't use Bootstrap in our project. But I can use Bulma instead.

One thing I found that when you are using Bulma you can activate the modal by just adding the is-active modifier on the .modal container.  The second thing is the Bulma does not include any JavaScript interaction. You will have to implement the class toggle by yourself if you need . So I tried to partially use the approach which was mentioned previously by @nehaSharma and wrote the following custom component:


<#if user.anonymous>
<!-- Modal card custom styles-->
...some code...
<!-- Modal card end-->

Could I just pass the required Board IDs using FreeMarker only with no JS involved? Thank you so much for your help!



Welcome to the Technology board!

Curious about our platform? Looking to connect on social technology? You've come to the right place!

Are you a Lithium customer? For direct assistance from our Support team, please visit the Support Forum.