Use of [cb:if] in Custom HTML field

2 years 9 months ago #325547 by yeatea
Use of [cb:if] in Custom HTML field was created by yeatea
Joomla 3.9.27
PHP 7.4
CB 2.6
GJ 3.5

Have set up a number of Group Jive groups, and messaging to group members set to email.
I wish to create a field that non-technical group owners can use to embed a logo specific to their group into emails.
I can set up individual fields for the logos, but do not want the owners to have to think (make a mistake!) about which field to embed. I created a Custom HTML field with [cb:if] [cb:elseif] logic to determine the header logo from their group, testing on [group]. Although [group] substitutes in the group name correctly, the logic does not work - it is wrapped in paragraph designators (<p> </p>) and displayed as text in the email.
Is there a way to achieve this.

Please Log in to join the conversation.

2 years 9 months ago #325550 by krileon
Replied by krileon on topic Use of [cb:if] in Custom HTML field
You should be able to use an image field and just directly substitute that into the GROUP_MESSAGE language string. Example as follows using CBs built in language overrides feature.

Key: GROUP_MESSAGE
Text:
Group [group] has sent the following message.<p>[message]</p><p>[cb:userfield field="cb_logofield" /]</p>


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

2 years 9 months ago #325556 by yeatea
Replied by yeatea on topic Use of [cb:if] in Custom HTML field
Kyle,
Sorry I don't think my original query was clear enough.
I appreciate the language string suggested is already present and places the group name in the top line of the email body.
I have tried your suggested solution to add logic into the override but this did not work for me. Using an image field type did nothing in the email,( but if tried on Profile just gave me a selector for a new image upload.) Anyway if it had worked would it not use the same logo for each group? If [cb_logofield] is a real field then I could not get it to do anything.

I can achieve a single logo by simply creating individual Custom HTML fields containing something like

<p><img src="full url/WCC_DPG_header.jpg" alt="" /></p>
and asking my group owners to use the field appropriate to them in their email.

We use a different logo for each group, and therefore wish to use the one appropriate to the group in the email. I would prefer not to ask our non-technical group owners to have to remember which field substitute to use to display their own particular logo. I was hoping to have one "mail_header" field which contained logic that by interrogating the value of [group] would allow me to determine which logo to use, eg

[cb:if [group]="AVG"]<img src=url of AVG group logo>[cb:elseif [group]="GPG"]<img src=url of CPG group logo>[cb:elseif. . . . . . . . .[/cb:if]

However, wherever I put this logic - as a language string override, or Custom HTML field it just gets wrapped in the paragraph designators and is printed as text.
Appreciate any further thoughts.

Regards

Please Log in to join the conversation.

2 years 9 months ago #325561 by krileon
Replied by krileon on topic Use of [cb:if] in Custom HTML field

If [cb_logofield] is a real field then I could not get it to do anything.

It doesn't exist. You need to create that field. Users would then just upload their logo to it and it should attach to the email.

I can achieve a single logo by simply creating individual Custom HTML fields containing something like

<p><img src="full url/WCC_DPG_header.jpg" alt="" /></p>
and asking my group owners to use the field appropriate to them in their email.

You're wanting to allow users to add their own substitutions to emails does not exist. Allowing that would be a vulnerability as they could use substitutions to get access to profile data they normally would not have access to.

However, wherever I put this logic - as a language string override, or Custom HTML field it just gets wrapped in the paragraph designators and is printed as text.

That won't work because that syntax is not valid. The syntax is strictly defined in our substitution tutorial below. If the syntax you are trying to use does not exist there then it is not valid.

www.joomlapolis.com/documentation/279-community-builder/tutorials/18353-using-substitutions-throughout-cb

However it is possible to do that IF condition, but with proper syntax. The emails sent by GJ have the following additional substitutions.

category_id
category_name
category_description
category
group_id
group_name
group_description
group
user

So you could have the following for example.

[cb:if group_id="GROUP_ID_HERE"]IMAGE_HERE[/cb:if]

Where GROUP_ID_HERE is replace it with the id of the group you want to condition against then add its relevant logo to IMAGE_HERE.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

2 years 9 months ago #325568 by yeatea
Replied by yeatea on topic Use of [cb:if] in Custom HTML field
Thanks for your help. This is my understanding, after lots of trials.

As you suggested I can apply the logic directly in the email body, and it works fine.
Also, simple substitution works fine in the email.
However [cb:if] logic does not appear to work in a field (of any type) that is substituted into the email body.

Therefore I will set up individual fields for the email headers for each group owner to use.

Are there any plans for a more configurable front-end email message system that would allow attachments say?

Please Log in to join the conversation.

2 years 9 months ago - 2 years 9 months ago #325570 by krileon
Replied by krileon on topic Use of [cb:if] in Custom HTML field

However [cb:if] logic does not appear to work in a field (of any type) that is substituted into the email body.

Correct, you can't nest substitutions inside of content that is substituted in. That would be a vulnerability if it was allowed. You will not have access to group_id for example in your Custom HTML field you're substituting in.

Are there any plans for a more configurable front-end email message system that would allow attachments say?

Yes, we plan to support email templates in a future release. We will likely just use Joomlas built in email template system in Joomla 4. Does appear to allow attachments if you configure an attachments folder, but I'm not entirely sure how it works at this time.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: yeatea

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.220 seconds

Facebook Twitter LinkedIn