Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

Cannot get [cb:if tests to work for some reason

8 years 8 months ago #277426 by STUCKSHUTTER
I think I've followed all the examples and found and read all the posts about this but I'm stumped trying to get the cb:if substitutions to work. I installed the content bot you recommended and can see my data in articles when logged in as a user.

Taking baby steps, I'm trying to use the user_id field in a select statement until I get something working. This is the statement I am trying to use: [cb:if user_id="0"]I am A GUEST.[/cb:if] I pretty much copied it out of the examples.

I presume I'm missing something but I have created six or seven variants of the example and no matter what I do, I only see the [cb:if statement show in the article indicating some kind of syntax problem or something but I can't figure out what.

What am I failing to do to get the statement to execute in an article?

Thanks for your help, sorry to have to bother you but I guess I am stupmped.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48460
  • Thanks: 8280
  • Karma: 1443
8 years 8 months ago #277451 by krileon
You need to surround substitution usages in Joomla content with {cb}SUBSTITUTIONS{/cb}. This is noted in the download description and the content plugins description. Also note substitutions without user parameter will be based off the article owner. If you want substitutions based off the viewing users profile data you need to use user="#me".


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.

8 years 8 months ago #277470 by STUCKSHUTTER
Replied by STUCKSHUTTER on topic Cannot get [cb:if tests to work for some reason
Thanks Kyle, that got me going on the substitutions. I can now substitute a user_id if the user is not logged in. However, I'm still struggling with some aspects of how to use substitutions. I hope you don't mind my asking but I'm drawing a blank which means I'm missing something important about how this feature works:

This is my question: How to use substitutions so the data displayed is based off of the substituted user_id?

How would you use the replacement user id (564) where there is no logged in user to show say the user_id (or other cb field) data for user 564?

i.e., Assume there is a CB field "cb_cityname" that contains "Atlanta" for user 564
How would the cb:if read so the result would display the information: "CITY NAME is Atlanta" in the following statement (that doesn't work) when there is no logged in user?
{cb}[cb:if user_id = "0" user_id ="564"] CITY NAME IS: [cb_cityname] [/cb:if]{/cb}

Obviouly something about the construction of this type of statement is unclear in my mind. Can you help me understand how to construct the statement so I get the result I'm looking for?

Thank you

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48460
  • Thanks: 8280
  • Karma: 1443
8 years 8 months ago #277528 by krileon
Substitutions in Joomla content by default substitute based off the content owner. So you need to specific the user as #me for viewing user or you need to edit CB Content Bot in Extensions > Plugins and change the target user so it's always based off the viewer. Below is an example if left configured as default.

[cb:if user="#me" user_id<="0"][cb:userfield field="FIELD_NAME" user="564" /][/cb:if]
[cb:if user="#me" user_id>"0"][cb:userfield field="FIELD_NAME" user="#me" /][/cb:if]

Please read the below substitution tutorial carefully. Bottom of the page has several IF examples.

www.joomlapolis.com/support/tutorials/107-use-cases/18353-using-substitutions-throughout-cb

The user parameter usage is explained within "Original Field Value" usage as well.


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: STUCKSHUTTER

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

8 years 8 months ago #277540 by STUCKSHUTTER
Replied by STUCKSHUTTER on topic Cannot get [cb:if tests to work for some reason
Thanks Kyle, the example let me understand what was going on and how to use this. Worked like a charm. And, thanks for the tip on the Content Bot, might be a way to simplify how to set this.

Substitutions are such a great feature, I'd sure recommend you think about reworking the documentation to show more examples of use and even do a video tutorial on it. It's a super feature that deserves a lot more exposure and "How you can use it" sort of information.

Much appreciated.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48460
  • Thanks: 8280
  • Karma: 1443
8 years 8 months ago #277556 by krileon
We'll be improving basically all our documentation significantly after we've launched our new site. Right now we don't have the tools to exactly make online documents easy to write or manage, but the new site will. We also have a lot of videos below.

www.youtube.com/user/Joomlapolis/playlists

There's a few videos about substitution usage.


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