November Happy Hour will be moved to Thursday December 5th.

Remove empty div if ContentArea has an active visitor gourp and block is hidden

ZZ
ZZ
Vote:
 

Hi.

I am facing this issue that I want to remove empty div if there is an active visitor group on the block.

This is a content area which will only contain one block and that block is supposed to have visitor group (e.g. persons age < 35  )

When the person is over 35 the block is hidder but there is still an empty div. How can I remove that ?

<div class="col-xs-12 col-md-6 col-lg-3"> 
@Html.PropertyFor(x => x.CurrentPage.ContentArea)
</div>
#267386
Nov 25, 2021 13:58
Vote:
 

Hi,

You can check the content area items and see if any items are returned.

It is preferable to use the filtereditems property as this will apply personalization, etc.

More info can be found here https://www.jondjones.com/learn-episerver-cms/episerver-developers-tutorials/common-web-page-component-tutorials/getting-items-within-an-episerver-content-area-in-code-items-and-filtereditems-explained/

Alternatively you could get the current users visitor groups and check if they are in the specific group. This method is more limited however.

https://support.optimizely.com/hc/en-us/articles/115002462051-Get-visitor-group-by-current-user

Paul

#268270
Dec 12, 2021 8:40
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.