Skip to Content Skip to Menu

[SOLVED] GroupJive Category based on CB Field

  • softforge
  • softforge
  • OFFLINE
  • Posts: 129
  • Thanks: 21
  • Karma: 12
15 years 2 months ago #110093 by softforge
I have a new project for CBSubs which will require a group to be created in GroupJive for a particular subscription. This is fine as I have seen that the CBSubs GroupJive plugin can do this.

However, I noticed that you have to choose the category for the group to be created in. We have a single select drop down field called cb_sector which exactly matches the category names in GroupJive. What we need is for the group to be created in the category that the user has selected in their cb_sector field.

Is this possible currently or in the next version or CBSubs? If not, would it be possible to use the SQL Actions plugin to do this?

Many thanks in advance! :)

Post edited by: krileon, at: 2009/09/07 03:05

If you like our plugins, please consider writing a review on the Joomla Extension Directory or the Community Builder Directory ...

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
15 years 2 months ago #110102 by krileon
Replied by krileon on topic Re:GroupJive Category based on CB Field
Easily done using SQL Actions. The majority of the plugins can be or are done with just queries. We used integration plugins to make it simple. However, for in-depth usage of a component I would suggest using queries. Yes, you can do this for groupjive with a query as SQL Actions supports substitutions.

Here are example queries, both will need to be ran. One creates the group. The other inserts the user into the group.

[code:1]
INSERT INTO `#__gj_groups` ( `name`, `descr`, `date_s`, `type`, `creator`, `user_id`, `active`, `category` ) VALUES ( 'My Group', 'My Group Description', NOW(), 1, '[username]', [user_id], 1, [cb_gjcategoryID] );
INSERT INTO `#__gj_users` ( `id_user`, `id_group`, `date`, `status` ) VALUES ( [user_id], '', NOW(), 'active' );
[/code:1]

Complex SQL is going to be needed to grab some IDs. Such as groupid and categoryid. Using a standard drop-down field from field management will not return a categories ID, but its name instead. So you need to do a select query inside the insert query to grab the ID.

Example:
[code:1]
INSERT INTO `#__gj_groups` ( `name`, `descr`, `date_s`, `type`, `creator`, `user_id`, `active`, `category` ) VALUES ( 'My Group - [user_id]', 'My Group Description', NOW(), 1, '[username]', [user_id], 1, ( SELECT `id` FROM `#__gj_grcategory` WHERE `catname` = '[cb_gjcategory]' ) );
INSERT INTO `#__gj_users` ( `id_user`, `id_group`, `date`, `status` ) VALUES ( [user_id], ( SELECT `id` FROM `#__gj_groups` WHERE `name` = 'My Group - [user_id]' ), NOW(), 'active' );
[/code:1]

As you can see I've done a select within an insert to get category ID and groupid. I've also changed the group name to be unique in order to grab its ID from database.

This is just an example! Ensure you make any necessary modifications and run any necessary testing. This has NOT been tested.


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.

  • softforge
  • softforge
  • OFFLINE
  • Posts: 129
  • Thanks: 21
  • Karma: 12
15 years 2 months ago #110119 by softforge
Replied by softforge on topic Re:GroupJive Category based on CB Field
Amazing! Thank you so much krileon!

Great idea to do a nested select query, I can defiantly get it working from this!

Thanks again :)

If you like our plugins, please consider writing a review on the Joomla Extension Directory or the Community Builder Directory ...

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

Moderators: beatnantkrileon
Powered by Kunena Forum