Hi Ashish,
Sounds like what you're after looks like functionality that is built into BC out the box.
- Create secure zone.
- Secure items to secure zone.
- Add CRM customers to secure zone - Subscribe customer to secure zone.
- Only logged in CRM customers who have access to the secure zone get access to the secured items.
If however you need to further extend this built-in functionality then lets address your question: how to duplicate PHP's in_array functionality.
Without delving too far into the intricate details, short answer: "you have to manually do it".
- I'd consider "stringifying" the array, then using the "contains" operator test for your conditions.
- Or get the securezone first, then compare when displaying the web app items.
Stringify using the {{ | join: ","}} filter then use contains to see if "Haystack" contains "Needle".
Filters | Business Catalyst Support
Here's an example I think could work. Optimise this yourself.
{% assign tutorStringified = tutors.items | join: "|" %}
{% if tutorStringified contains item %}
Or method 2:
- First get your secure zone. (see below for a more efficient method to getting current secure zones.)
- Now loop through your web app items, looking and do the comparison between classified items and current secure zone.
{% for tutor in tutors.items %}
{% if tutors.classification contains securezoneName %}
<td><a href="{{tutor.urlWithHost}}">{{tutor.name}}</a></td>
{% endif -%}
{% endfor -%}
PS. instead of running two {module_data} to get the current user's secure zone, try the following which uses {{ globals.user.entityId }} to get the current logged in customer's CRM ID:
Instead of:
{module_data resource="customers" version="v3" collection="customerInfo" fields="id,firstName,middleName,lastName,email1,email2,email3,username,mobilePhone,wholes aler" where="\{'$or':\[\{'email1.value': '{{this.globals.user.email}}'\},\{'email2.value': '{{this.globals.user.email}}'\},\{'email3.value': '{{this.globals.user.email}}'\}\]\}"}
{%assign userInfo = customerInfo.items[0]%}
{module_data resource="customers" subresource="securezones" resourceId="{{userInfo.id}}" version="v3" template="" collection="customerZones"}
------------------
Try:
{%assign userInfo = globals.user.entityId %}
{module_data resource="customers" subresource="securezones" resourceId="{{userInfo}}" version="v3" template="" collection="customerZones"}
Hope this helps!