Skip to Content Skip to Menu

[SOLVED] cb:if not working when combined with cb:date

  • bascherz
  • bascherz
  • OFFLINE
  • Posts: 228
  • Thanks: 29
  • Karma: 11
3 years 11 months ago - 3 years 11 months ago #322030 by bascherz
Why isn't this working?

Code:
[cb:if '[value]'='']Not Yet[cb:else][cb:date format='M d, Y' date='[value]' /][/cb:else][/cb:if]

In the profile view it renders the value and even the formatted date, but the if/else appears to be ignored. It literally just shows the above with the unformatted and formatted dates replacing [value]. If I use double instead of single quotes, I get an HTML error. I am sure I am just doing something wrong.

Thanks in advance.
Bruce

Bruce S - Vienna, VA
Last edit: 3 years 11 months ago by krileon. Reason: Added [SOLVED] tag to subject

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 #322036 by krileon
Replied by krileon on topic cb:if not working when combined with cb:date
It's not working because that's not a valid syntax. See our below substitution tutorial for usage information.

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

If the syntax is not in the tutorial it's not valid. There are extremely few exceptions to this like format functions in CB Auto Actions which have more nesting flexibility.

In your case for field layouts [value] is replaced last after all other substitutions so you can not nest it like that. You need to use the raw [FIELD_NAME] substitution if you need the fields raw value in your layout.


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.

  • bascherz
  • bascherz
  • OFFLINE
  • Posts: 228
  • Thanks: 29
  • Karma: 11
3 years 11 months ago #322052 by bascherz
Replied by bascherz on topic cb:if not working when combined with cb:date
I'm actually not sure what nesting you're referring to. Even if I do any of these, the first of which is right in the substitutions tutorial (at least the way I read it), it does not work.
Code:
[cb:date format='M d, Y' date='[value]' /]
Code:
[cb:userfield field='cb_cookieacceptdate' date='[cb_cookieacceptdate]' format='M d, Y' /]
So I have to assume you mean using [value] in the cb:date function is "nesting". I don't consider [value] to be a function (it's a value placeholder), so it's a bit confusing.
Even this isn't working.
Code:
[cb:if '[value]'='']Not Yet[cb:else][value][/cb:else][/cb:if]
So I am sure I am just not understanding the tutorial.

Bruce S - Vienna, VA

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 #322062 by krileon
Replied by krileon on topic cb:if not working when combined with cb:date

I'm actually not sure what nesting you're referring to. Even if I do any of these, the first of which is right in the substitutions tutorial (at least the way I read it), it does not work.

Again, your syntax is wrong. You keep using single quotes and no where in the tutorial does it have you using single quotes. Please follow the syntax exactly as provided. We even have a nested substitution tutorial showing an exact usecase similar to your own.

[cb:userdata field="username" user="[cb_mentor]" /]

Regarding [value] I have already explained above you can not use [value]. That is a special substitution for field Layout parameters. It is replaced after substitutions this means you can't use it in your substitution like that. You need to instead use a raw [FIELD_NAME] substitution like the following.

[cb:date format="Y-m-d" date="[cb_mydatefield]" /]

Even this isn't working.

I can't see why that would possibly work. No where in our tutorial do we hint you can lead with a substitution like that. Specifically the below does not exist in our syntax.

[cb:if '[value]'='']

In addition to that syntax not existing you again keep using single quotes which are not supported by our substitution REGEXP so they won't even be parsed.


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.

  • bascherz
  • bascherz
  • OFFLINE
  • Posts: 228
  • Thanks: 29
  • Karma: 11
3 years 11 months ago #322078 by bascherz
Replied by bascherz on topic cb:if not working when combined with cb:date
This is what worked:
Code:
[cb:if user="#displayed" cb_cookieacceptdate="0000-00-00"]Not Yet[cb:else][cb:date format="F d, Y" date="[cb_cookieacceptdate]" /][/cb:else][/cb:if]

Simple enough, I suppose.

Thanks, Kyle!

Bruce S - Vienna, VA
The following user(s) said Thank You: krileon

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

Moderators: beatnantkrileon
Powered by Kunena Forum