Skip to Content Skip to Menu

How to insert a CB String into an output from AA

  • timstohr
  • timstohr
  • OFFLINE
  • Posts: 1091
  • Thanks: 56
  • Karma: 9
3 years 11 months ago #322090 by timstohr
Hi Kyle,
I have created a quite unusual Auto Action. In effect, it is a stream but it has a button at the top where you can create events which are then presented on the stream.

Since I have a multilingual website, I would need the message of the button not to be hard coded but a constant.

Please see the attached picture, it sums the problem up the best and most concise. The stuff where I need to put in the string has been highlighted.


I have tried several things but nothing seems to work.

Any pointers how I can insert a string in there?

Thanks

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48548
  • Thanks: 8290
  • Karma: 1445
3 years 11 months ago #322093 by krileon
You can either use our CBTxt API or enable format functions for your auto action under the parameters tab and use the translate format function. You can then use language overrides to translate it as needed.


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 or Create an account to join the conversation.

  • timstohr
  • timstohr
  • OFFLINE
  • Posts: 1091
  • Thanks: 56
  • Karma: 9
3 years 11 months ago #322095 by timstohr
Hi,
How to do I use the CBTxt API? I have tried using it but actually nothing came out of it.

Could you give me some example code that I should put in there?
Here is what I have tried already to put in the highlighted stuff: <?php echo JText::_('EB_EVENT_CREATE'); ?>, JText::_('EB_EVENT_CREATE'), <?php echo CBTxt::T('EB_EVENT_CREATE'); ?>.

Some example would be great than I can use it in other usecases I have.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48548
  • Thanks: 8290
  • Karma: 1445
3 years 10 months ago #322126 by krileon
Do not put php tags in the Code action. Just put raw PHP in it. As for CBTxt it's used as follows.

Text as Key
Code:
$myString = CBTxt::T( 'Hello!' );

Language Key
Code:
$myString = CBTxt::T( 'MY_LANG_KEY' );

Language Key with Text
Code:
$myString = CBTxt::T( 'MY_LANG_KEY', 'Hello!' );

Inside of the code action you'll probably have to use the full namespaced path as shown below.

Code:
$myString = \CBLib\Language\CBTxt::T( 'Hello!' );

It would be far easier to simply use the translate format function though.


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 or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum