Accessing CB in other Modules

15 years 4 months ago #81229 by makario
Accessing CB in other Modules was created by makario
All right. I'm going to have trouble wording this request.

I am using the Jobline component as a way to post job notices for my site. A user can submit applications to a client through Jobline. When a user submits an application, he has to fill out his contact information, and then it is sent by email.

I'm trying to reduce redundancy by automatically filling in a lot of the fields (name, age, location, etc) by using the content from CB. I'm new to PHP and MySQL, so how can I look up a user's id, grab information, and use it in my Jobline module?

I would also like a way to email a user's profile picture. I don't have to send an attachment, I just need away to grab the image source url so I can use it in my HTML emails.

Thanks in advance!

Please Log in to join the conversation.

15 years 4 months ago #81262 by krileon
Replied by krileon on topic Re:Accessing CB in other Modules
[code:1]
global $database, $my, $mosConfig_live_site;
$database->setQuery("SELECT * FROM #__comprofiler WHERE user_id=".$my->id);
$results = $database->loadObjectList();
if ($results) foreach ($results as $user) {
YOUR FORM HERE
}
[/code:1]

In your form use the values as $user->(field).

Avatar is different as only the image name and type are saved to database. You need to define the path to the images first, which is YOURSITE/images/comprofiler/tn.

So(example):
[code:1]
echo "<img border=0 src='".$mosConfig_live_site."/images/comprofiler/tn".$user->avatar."' />";
[/code:1]

This is just one of the many ways to go about it, but I hope this gets you started. If the component has 2 parts (1 HTML and 1 CODE). Then place the query into the code page and have the function pull the results to the HTML page.

Post edited by: krileon, at: 2008/12/04 17:00


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.

15 years 4 months ago #81266 by makario
Replied by makario on topic Re:Accessing CB in other Modules
Thanks for your help. I'm understanding.

But I get an error:

Fatal error: Call to a member function setQuery() on a non-object in /home/thedirec/public_html/components/com_jobline/jobline.html.php on line 198


I'm guessing that this means that there is something wrong with the line:

[code:1]$database->setQuery("SELECT * FROM #__comprofiler WHERE user_id=".$my->id);[/code:1]

What would that be?

Please Log in to join the conversation.

15 years 4 months ago #81268 by krileon
Replied by krileon on topic Re:Accessing CB in other Modules
Did you put the globals in?


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.

15 years 4 months ago #81270 by makario
Replied by makario on topic Re:Accessing CB in other Modules
Never mind, I figured it out! I didn't put in the first database global.

It works great. Thanks for your help.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.207 seconds

Facebook Twitter LinkedIn