Skip to Content Skip to Menu

calling cb field values via php

  • natbarre
  • natbarre
  • OFFLINE
  • Posts: 15
  • Thanks: 2
  • Karma: 0
12 years 11 months ago - 12 years 11 months ago #180628 by natbarre
calling cb field values via php was created by natbarre
Hello, I'm using cb1.7 and cbsubs. I use CB CONTENT on my site already, but would like to be able to display the CB CONTENT field conditionally, based upon the presence of another field from another table.
I'm not the best at php.
Can I insert the {cb:[cb_2]},{cb:[cb:userfield field="cb_2" /]}, or [cb_2] into a php echo? What about mysql query? It just displays the original text. Is it my syntax or an incompatibility with the substitution.

<?php
if ($num1 > 0) {
echo '{cb:[cb_2]}
';
}
?>

thoroughly confused!
fyi: i'm using jumi to inject the php into an article.

Thanks, Nat
This php works, and prints
Last edit: 12 years 11 months ago by natbarre.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48435
  • Thanks: 8275
  • Karma: 1443
12 years 11 months ago #180690 by krileon
Replied by krileon on topic Re: calling cb field values via php
If you've CB Content Bot (incubator project) installed you could just use substitutions to render your fields in your article directly. There would be no need for PHP. Please better clarify what you're wanting to do. CB can't render fields from non-CB databases through its API.


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.

  • natbarre
  • natbarre
  • OFFLINE
  • Posts: 15
  • Thanks: 2
  • Karma: 0
12 years 11 months ago #180705 by natbarre
Replied by natbarre on topic Re: calling cb field values via php
I am using cb content bot to display the values of a custom cb field (cb_1). However, I would like to use a php if clause to display or not display the custom cb field dependent upon the value of another variable(not a cb variable).

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48435
  • Thanks: 8275
  • Karma: 1443
12 years 11 months ago #180720 by krileon
Replied by krileon on topic Re: calling cb field values via php
I see, then you should just echo your substitution if the IF statement is true. Example as follows.
Code:
<php if ( $value == 123 ) { echo '{cb:[username]}'; } ?>

No experience with your plugin that allows PHP in articles so no idea if that'll work or not. You may want to ensure that the plugin order in Joomla plugin manager has your PHP parsing plugin first so it can first determine if the substitution should be echoed in or not.


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