Skip to Content Skip to Menu

Queries maybe? To pull fields of a specific group?

12 years 4 months ago #202040 by marriage_minded_man
Replied by marriage_minded_man on topic Re: Queries maybe? To pull fields of a specific group?
Ok, I'm figuring this out.

Few things.

1. I don't want the output to be displayed based on the group id of the viewer. I want the output to be produced based on the group id of the user in the database. So if the user in the database has a gid of "17" for example, then I want their information to be displayed. I think you may have given a gid if statement based on the viewer, if I'm not mistaken.

2. ok, 2 questions about the query. So the first part (query section) is selecting the table then, the row section is outputting the field values. How do you output 2 fields from 2 different tables, like "username" (from #__users) then "youtubeusername" from #__comprofiler. So that I can have the username of the user on top of their embedded channel, preferrably linked to their profile.

The second question; How can I output the rows where this specific field is filled out. I don't want to output a row if the "youtubeusername" field is not filled in.

Sorry, I know I'm asking some MySQL stuff here, but it's a quick explanation fix, I'll take it, if not then I will have to learn more MySQL stuff.

So in short, display [username] and [youtubeusername] based on these 2 things; gid of user in db, and based on whether the youtubeusername field is filled or not.

Please, and Thank you very much ??? :unsure:

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48444
  • Thanks: 8279
  • Karma: 1443
12 years 4 months ago #202085 by krileon

1. I don't want the output to be displayed based on the group id of the viewer. I want the output to be produced based on the group id of the user in the database. So if the user in the database has a gid of "17" for example, then I want their information to be displayed. I think you may have given a gid if statement based on the viewer, if I'm not mistaken.

All substitutions in a delimiter field displayed on profile. So if you add an IF statement to the delimiter field it'll be based off the users profile you're viewing and not the user viewing the profile; this can be changed using user="#me" though so it's based off the user viewing the profile.

2. ok, 2 questions about the query. So the first part (query section) is selecting the table then, the row section is outputting the field values. How do you output 2 fields from 2 different tables, like "username" (from #__users) then "youtubeusername" from #__comprofiler. So that I can have the username of the user on top of their embedded channel, preferrably linked to their profile.

You use a column substitution as shown in my example. Another example as follows.

Row:
Code:
<div>[column_username] - [column_name]</div>

So in short, display [username] and [youtubeusername] based on these 2 things; gid of user in db, and based on whether the youtubeusername field is filled or not.

Don't think you need CB Query Field for that if both are fields. Example as follows.

[cb:if gids includes "8" and cb_youtubeusername!=""][username] - [cb_youtubeusername][/cb:if]


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.

12 years 4 months ago #202089 by marriage_minded_man
Replied by marriage_minded_man on topic Re: Queries maybe? To pull fields of a specific group?
Ok. The problem is it's not gonna be on the user profiles.

I want to have a specific page that just floats a whole bunch of divs with this information being pulled from the DB.

So for example a Youtube channel page where all the Youtube channels of users in that specific group are displayed. So the viewer can see a whole bunch of youtube channels with the Username of the owner of that channel on top. I think that's why I need the query field to pull these things out of the DB, because its not gonna go through a profile. Sorry I wasn't clear about this.

So maybe I would use Content Bot to display this page, with the information of these users (that are in this specific group) displayed for anyone to see. I'm sorry, I hope that makes sense. Thank you for your patience.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48444
  • Thanks: 8279
  • Karma: 1443
12 years 4 months ago #202099 by krileon
If the Youtube Username is stored as a field then just query the _comprofiler database with the CB Query Field plugin and output each row however you want (rows support substitutions). The query can select whatever information you want and output whatever columns you want. You could then substitute that query field into an article using CB Content Bot with the IF statement surrounding the query field substitution. It doesn't really matter who the user is for the substitution because the query field is pulling everyones youtube usernames.


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.

12 years 4 months ago #202118 by marriage_minded_man
Replied by marriage_minded_man on topic Re: Queries maybe? To pull fields of a specific group?
Ok, I'm almost there. And I think you should give yourself a raise and a vacation, because you've worked extra hard on this and I appreciate it.

Some users have a youtube username filled in and some don't. So how do I only display the fields that have it filled in? I don't want to display empty fields. So is there a "Select IF not NULL" or something like that.

Here is what I have:


CB Query Field: cb_queryfield

Query: SELECT * FROM `#__comprofiler`

Mode: Internal

Output: Multiple Rows

Row: Youtubecode [column_cb_youtubeusername] endyoutubecode



Then in the article:

{cb:[cb:userfield field="cb_queryfield" /]}


This displays a channel for every field even if its empty (because the row is surrounded by the youtube code). How can I query only the non-empty fields so that the empty ones don't show in a channel? Maybe like a select from #__comprofiler if not null?


The second problem I'm having is that I want to display their CB username on top of their channel so that the row would look like this:

Row: <a href="profileurl"> [column_username] </a> <br> Youtubecode [column_cb_youtubeusername] endyoutubecode

However the username is part of a different table (not #__comprofiler), which is #__users. Can I do this all in the same query?

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

12 years 4 months ago #202166 by marriage_minded_man
Replied by marriage_minded_man on topic Re: Queries maybe? To pull fields of a specific group?
Ok. I think I solved both problems, sort of.

Im using the WHERE operator in MYSQL query (yes, Ive been doing a lot of googling). So it looks like this.

SELECT * FROM `#__comprofiler` WHERE cb_youtubeusername!=""

So this only pulls the youtubeusername field only if it's filled in. Good enough.

I couldnt figure out how to pull the cb/joomla username from the "#__users" table in order to display it along with the code. So I just used their "user_id" to construct a URL to their profile like this.

<a href="index.php?option=com_comprofiler&task=userprofile&user=[column_user_id]" target="_top">Click Here For My Profile</a>[column_user_id]

Along with the youtubeusername output in the same row.

I noticed that if I hardcode that link, it asks them to login, even if they already are. And for some reason when that link is clicked the profile page appears with no modules on it, so I used a "?Itemid=564" from some other menu item in order to display the modules and menus on the profile page. I guess Joomla use itemid to construct pages as far as modules and page structure goes?

Sort of hacking my way through this, I'm sure someone more knowledgeable would do a cleaner job. Let me know if you see anything that I should be cautious of.

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

Moderators: beatnantkrileon
Powered by Kunena Forum