Forum for discussing general topics related to Couch.
4 posts Page 1 of 1
hi couchies,

I'm building a webapplication where we destinct members based on their e-mailadresses. If the e-mailadress ends with "@companyname.com" I want to display different content than when the email adress ends with "@adifferentcompany.com". Is it possible to create such an if formula?
It would be a lot of work to create an extra field for the company name and check per member if they are truly working in this company. Using the emailadress would be a nice way to check this for us.

Thanks
Hi Saskia,

We can extract the domain from mail address using a bit of PHP -
Code: Select all
<cms:php>
    global $CTX;
    $mail = explode( '@', $CTX->get('my_mail') );
    $CTX->set( 'my_mail_domain', $mail[1], 'global' );
</cms:php>

The example code above assumes the editable region containing the email is named 'my_mail'. Please change it to the name of your actual editable region.

The code extracts the domain part from 'my_mail' and sets that in another variable named 'my_mail_domain'.

So now you can simply use that variable in your decision making e.g.
Code: Select all
<cms:if my_mail_domain='mycompany.com'>
...
</cms:if>

Hope it helps.
Awesome, thanks KK!
You are welcome :)
4 posts Page 1 of 1
cron