Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Checkbox visible for particular country only

Avatar

Level 4

Hi,

I am trying to develop a dialog that has a checkbox which has to be visible to only a particular country. For example, in component dialog i added checkbox with xtype selection then that checkbox should be visible for pages under china only not for other countries.  

What would be the best way to implement it? Can we do it using listeners? If listeners, then which method is the best to use?

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Yes, it would be easy to implement via listeners,

You can add loadcontent listeners to dialog. This would fire when you open your dialog. You can write JS code in listener to check / uncheck listener

thanks

View solution in original post

4 Replies

Avatar

Correct answer by
Level 10

Hi,

Yes, it would be easy to implement via listeners,

You can add loadcontent listeners to dialog. This would fire when you open your dialog. You can write JS code in listener to check / uncheck listener

thanks

Avatar

Level 10

but before writing a listeners, we may have to look at if its the right approach ?

To get to the best approach couple of questions. Is that the country is a different site ??

if its a different site, then I would say to override this component dialog for that site and add the checkbox.

Avatar

Former Community Member

Any attempt to block access can be bypassed just as easily or easier than applying the block in the first place. All the person needs is VPN access to a location that you don't have blocked so that all their traffic appears to come from there.

The measures you suggest will prevent you wasting bandwidth on people who have accidentally selected your site when they are really looking for one located elsewhere but it will not stop someone who deliberately wants access to your site..Chances are that a small percentage of the visitors your stats say are located in the US are actually located elsewhere.

Avatar

Level 4

bsloki wrote...

but before writing a listeners, we may have to look at if its the right approach ?

To get to the best approach couple of questions. Is that the country is a different site ??

if its a different site, then I would say to override this component dialog for that site and add the checkbox.

 

Yes, the country is a different site. I tried using the listener approach something like this : The component for which i am changing is a global component. Almost 20 components include this using cqinclude it in their dialogs. So, if we add a checkbox it shows up globally. I tried to write listener "loadcontent" in which i check for country code and then i wrote

"this.findParentByType('dialog').getField('./english').hide();"

 this is supposed to hide the checkbox for all countries except one country. But it is not the result, i don't see any change. When i use the same code for another dialogs or fields which are not global, it worked properly.

So, my question is how can i successfully hide the checkbox in a component which is shared globally?