Skip to Content Skip to Menu

[SOLVED] Formating date field in article with cb content bot

  • agaudin
  • agaudin
  • OFFLINE
  • Posts: 82
  • Thanks: 16
  • Karma: 3
7 years 2 days ago - 7 years 2 days ago #298432 by agaudin
Hi again,

I am using the CB content bot to produce personnalized articles and it works fine, including substitutions and conditionnal replacements.

I am encountering a difficulty with a date field :
- it's OK to personnalize the ""today" date [cb:date format="d/m/Y" /]
- but I cannot give the d/m/Y format to a date from database called with substitution [cb_date_paiement]
---- no problem to get the raw SQL field which is Y-m-d formatted
---- I tried almost all combinaisons coming from this page www.joomlapolis.com/documentation/18353-using-substitutions-throughout-cb including [cb:userdata field="[cb_date_paiement]" /] and [cb:userfield field="[cb_date_paiement]" /] with and without several kind of formatting rules like format="Y-m-d" / included in the substitution string - none of them worked
---- I looked across forums but without any idea.

Thanks a lot by advance if you can explain me the trick I probably have missed.

Best regards,
Antoine
Last edit: 7 years 2 days ago by krileon. Reason: Added [SOLVED] tag to subject

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48444
  • Thanks: 8279
  • Karma: 1443
7 years 2 days ago #298433 by krileon
[cb:date format="PHP_DATE()_FORMAT" /] strictly only accepts PHP date() function formats. It also strictly only formats the current datetime. If you want to output a date or datetime field formatted you need to use [cb:userfield field="FIELD_NAME" /] otherwise [FIELD_NAME] is raw database value. So for example in your case you'd have the below.

[cb:userfield field="cb_date_paiement" /]


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.

  • agaudin
  • agaudin
  • OFFLINE
  • Posts: 82
  • Thanks: 16
  • Karma: 3
7 years 2 days ago #298435 by agaudin
Thanx a lot for your answer - unfortunately I already tried (and tried once again after your reply) but it didn't work :

Code of the article : Mode de paiement : [cb:userfield field="cb_date_paiement" format="d/m/Y" /]

Display : Mode de paiement : [cb:userfield field="cb_date_paiement" format="d/m/Y" /]
which means my way of doing thing is obviously not working.

I'm certainly missing something... the question is what ? ;-)

Thanx by advance.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48444
  • Thanks: 8279
  • Karma: 1443
7 years 2 days ago #298436 by krileon

Code of the article : Mode de paiement : [cb:userfield field="cb_date_paiement" format="d/m/Y" /]

Display : Mode de paiement : [cb:userfield field="cb_date_paiement" format="d/m/Y" /]
which means my way of doing thing is obviously not working.

No where in the substitution tutorial does it say you can do this. When using [cb:userfield field="FIELD_NAME" /] for a date or datetime field it will output in whatever format is configured in the field it self. You can not reformat it from a substitution.


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.

  • agaudin
  • agaudin
  • OFFLINE
  • Posts: 82
  • Thanks: 16
  • Karma: 3
7 years 2 days ago #298439 by agaudin

krileon wrote:

Code of the article : Mode de paiement : [cb:userfield field="cb_date_paiement" format="d/m/Y" /]

Display : Mode de paiement : [cb:userfield field="cb_date_paiement" format="d/m/Y" /]
which means my way of doing thing is obviously not working.

No where in the substitution tutorial does it say you can do this. When using [cb:userfield field="FIELD_NAME" /] for a date or datetime field it will output in whatever format is configured in the field it self. You can not reformat it from a substitution.


OK - I missconfused the two ways of typing - sorry for that. Things get clearer, tanks !

Unfortunately, what you're recommanding [cb:userfield field="cb_date_paiement" /] displays nothing (blank output).
So I can use only the raw output [cb_date_paiement] which is a SQL date, with the format yyyy-mm-dd.

Any idea why the [cb:userfield field="FIELD_NAME" /] does not work ?

Best regard,

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48444
  • Thanks: 8279
  • Karma: 1443
7 years 2 days ago #298441 by krileon

Unfortunately, what you're recommanding [cb:userfield field="cb_date_paiement" /] displays nothing (blank output).

For userfield substitutions the fields access is respected. This means the field needs to be set to display on profile and be on an accessible tab. If you don't actually want it visible on profile then move the tab to a not shown on profile position so the substitution can still display the fields on that tab.


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