Conditional display

Tag Structure

{if:VARIABLE OPERATOR VALUE}...text you want to display or remove...{/if}

You can use any variable from the user profile (so name, email, subid, userid or any other custom field you created) You can use the operators:

  • = (which means equal)

  • != (which means different)

  • > (superior to)

  • < (inferior to)

  • ~ (contains the string)

  • !~ (does not contain the string)

The test is case-insensitive.

You can also use values returned by another tag in the conditional display by using the format: {if:var.{yourtaghere}=3}...{/if} For example if you created a field on Community Builder: {if:var.{tagcb:cb_gender}=M}this text will be displayed for Male{/if}

You can also test based on Joomla profile values using the format: {if:joomla.joomlafield=value}...{/if}

Examples

Display text for registered users only

{if:userid!=0}You're one of our registered users!{/if}

Display text for visitors (users without a Joomla account) only

{if:userid=0}What? You're not a registered user?? Let's create your account now!{/if}

Display text based on the user's interests (created with the AcyMailing Enterprise custom fields)

If you create a custom field with checkboxes to select user's interests, you should then use the operator "~" as a user may have several interests. {if:mycats~sports}Here I will display sports articles{/if}

Display text if the field does not have value

{if:occupation= }You didn't enter your occupation... don't forget to update your profile on our website!{/if} (You should add a space after the operator)

Display text according to the list subscription

If you want to display some text according to the list subscription, you can use the tag giving all lists the user is subscribed to. Then search if your list name is inside: {if:var.{list:names}~your first list name}Message for your first list{/if} {if:var.{list:names}~your second list name}Message for your second list{/if}

Last updated