Skip to Content Skip to Menu

Where To Place API Code

  • mba90008
  • mba90008
  • OFFLINE
  • Posts: 10
  • Thanks: 1
  • Karma: 0
10 years 8 months ago - 10 years 8 months ago #240779 by mba90008
Where To Place API Code was created by mba90008
Hi...

Where would I place cb's API code within a component or module so it communicates with cb. I'm trying to connect cb to the rsforms pro component and one of its modules. I've tried to place the api code in places within the source files..where to me...seemed logical but all I keep getting are Fatal Errors. My most recent error was...

Fatal error: Call to a member function getParams() on a non-object in /home3/mba90008/public_html/sitetest/administrator/components/com_rsform/helpers/rsform.php on line 42

For the above error, I copied and pasted the api code at the top of the referenced file and then use the following code to grab the cb username for any profile displayed on the screen for a form value.

//<code>
global $_CB_framework;
$user =& CBuser::getUserDataInstance( $_CB_framework->displayedUser() );
return $user->get('username');
//</code>

The above snippet of code was attempting the following as illustrated here...

www.rsjoomla.com/support/documentation/view-article/77-display-php-variables-by-default-when-form-is-shown.html
Any suggestions or relating coding examples you can give me would be appreciated.

Thanks in advance!
Last edit: 10 years 8 months ago by mba90008. Reason: Typo

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48477
  • Thanks: 8281
  • Karma: 1443
10 years 8 months ago #240829 by krileon
Replied by krileon on topic Where To Place API Code
If the CB API is not yet loaded it needs to be included as instructed in the below tutorial.

www.joomlapolis.com/support/tutorials/120-api-usage/18357-including-cb-api-for-usage-outside-of-cb

Once included you can use CB API as normally. The username however is stored with the Joomla user object so you don't need CB API to grab that if that's all you need.


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.

  • mba90008
  • mba90008
  • OFFLINE
  • Posts: 10
  • Thanks: 1
  • Karma: 0
10 years 8 months ago #240884 by mba90008
Replied by mba90008 on topic Where To Place API Code
Hi...thanks for the reply back. But my question, more specifically, is where do I install the api code?


I've tried to copy and paste the code in a variety of source folders for both the component and the module...but I'm not getting it right because all I get is fatal errors. And the cb article that you referred me to doesn't specify where exactly the api should be placed so that will load.

I'm new to all this so my apology if I'm asking something that really basic in nature.

Thanks in advance.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48477
  • Thanks: 8281
  • Karma: 1443
10 years 8 months ago #240914 by krileon
Replied by krileon on topic Where To Place API Code

is where do I install the api code?

You normally include it right above your usage, but this is highly subjective to your usage.

but I'm not getting it right because all I get is fatal errors.

You need to provide any error messages you get for me to help you with them.

And the cb article that you referred me to doesn't specify where exactly the api should be placed so that will load.

It can't specify where it should go, because that's entirely based off what you're using it in. If it's a 3rd party extension then that maybe something you need to ask the developer about as it only needs to be included once when the extension is loaded so the CB API will be available throughout that extension.


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