How to bring $_CB_framework into other components

13 years 11 months ago #131424 by rvillafane
I am running Joomla 1.5.9 with Community Builder 1.2.2. I am trying to pre-populate a few fields with data that are already in CB (like name, email, phone number, etc) within a form component called BreezingForms. After reading the Community builder tutorials and the BreezingForms forums, I came up with the code listed below:
[code:1]$this->execPieceByName('ff_InitLib');

global $_CB_framework, $mainframe;

include_once( JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php' );
include_once( $mainframe->getCfg( 'absolute_path' ) . '/administrator/components/com_comprofiler/plugin.foundation.php' );

cbimport( 'cb.database' );
cbimport( 'cb.html' );
cbimport( 'cb.plugins' );

$myId = $_CB_framework->myId();
$cbUser =& CBuser::getInstance( $myId );
$user = $cbUser->getUserData();

ff_setValue('firstname', $user->firstname);
ff_setValue('lastname', $user->lastname);
ff_setValue('phone', $user->phone);
ff_setValue('email', $user->email);[/code:1]

After applying this code to the form, it doesn't work. I traced this issue and narrowed it down to not being unable to process the following variable within BreezingForms:
[code:1] $myId = $_CB_framework->myId();[/code:1]

When executed normally, the above code returns my CB ID (which is then used to get other CB profile information)--which we all know. However, when executed within BreezingForms, it constantly returns a zero for it's value. If I were to set the $myId string manually to my own ID, everything works and all fields get populated.

So my question is: How do I instantiate the CB framework within other components ($_CB_framework mainly)? Is there something I am missing? I spoke the BreezingForms support and that is the question they asked me to ask Joomlapolis.

Any help will be appreciated...:)

References:
- www.allmysocials.com/articles/1-tutorials
- crosstec.de/breezingforms-15-en-mainmenu-10.html


Thanks,
Rudy

Please Log in to join the conversation.

13 years 11 months ago #131445 by heyai
Maybe the following still works:

[code:1]global $my; [/code:1]

(described in the Hello World Plugin )

hey-ai - the community for asian guys and non-asian girls

The search bar is your friend, not just decoration!

Please Log in to join the conversation.

13 years 11 months ago #131496 by krileon
Your code seams correct, but how BreezeForms handles it is entirely up to the extension. I recommend you consult this with the developers of BreezeForms as CB API appears to be working perfectly fine. Using $my is not a native function and you lose Joomla native support by using it. Our Hello World Plugin is out of date currently and we do plan to update it.


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 to join the conversation.

13 years 11 months ago #131545 by rvillafane
Thanks for getting back to me on this.

After putting my nose in a PHP book I found out how the '$_CB_framework' object was imported via the global statement in the code(duh):
[code:1]global $_CB_framework, $mainframe;[/code:1]
One thing I realized while using the 'global' command, is that there is no error checking for non-existent global variables/objects (at least none that I was able to see with my limited PHP experience). Example:
[code:1]global $_CB_framework, $mainframe, $chowderhead240;[/code:1]
...this executes fine...appending the ficticious var/object '$chowderhead240' to the global statement produces no errors...

So, with that in mind, I used echo/print commands to test the ability to retrieve the objects previously mentioned in the global statement ($_CB_framework and $mainframe).
I found that I was able to print the contents of "$mainframe->getCfg( 'absolute_path' )" ok. However, when I attempt to print the contents of "$_CB_framework->myId()", I received the following error (instead of my CB ID):

*** EXCEPTION CAUGHT BY FACILEFORMS ***
PHP error level : E_NOTICE
PHP filename : /var/www/virtual/fixxx-new.org/htdocs/components/com_facileforms/facileforms.process.php(1047) : eval()'d code
PHP linenumber : 17
Last known pos : Before form piece test2 at line 1
Error message : Undefined property: CBframework::$myId


...Since the script is unable to find the 'myId' propery in the '$_CB_framework' object, it appears to me that there is an issue importing the '$_CB_framework' object into local context--unless I am missing something (please correct me).

With that in mind, I have the following questions:
  1. Is the '$_CB_framework' object a TRULY a global object?
    I ask because:
      - The '$mainframe' query works fine.
      So the import seems good on this.
      - The 'global' statement produce no visible errors for non-existent global vars/objects.
      (please let me know if I am wrong on this).
      - It appears like '$_CB_framework' is not importing properly.
      (if there is another way to test this, please let me know)
  2. Is there any additional code that needs to present in either the BreezingForms component or provided in my script that will allow me to properly import the '$_CB_framework' object?
  3. If we still feel this is a BreezingForms issue, what directions would anyone suggest I give their techsupport which will provide traction in resolving an issue like this?

Is just amazing that the rest of the code works and is hanging on acquiring the property of just this one object. :( Being so close, I am hoping the resolution is something that is simple and just unforeseen at the moment. I am open to any work-around suggestions anyone may have. --Ok... I am done whining :)

Thanks again,
Rudy

Post edited by: rvillafane, at: 2010/04/28 05:02

Please Log in to join the conversation.

13 years 10 months ago #131757 by krileon
Sorry, don't know what to advise; the API wasn't designed to be used in such a manner. Whether it'll work or not with BreezeForms I have no idea as I don't know how it's executing the code and if it's being done properly and if so if it's being cleaned properly or over cleaned. I again recommend contacting the developers of BreezeForms.


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 to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.253 seconds

Facebook Twitter LinkedIn