Skip to Content Skip to Menu

query field setup

  • liaskas
  • liaskas
  • OFFLINE
  • Posts: 382
  • Thanks: 36
  • Karma: 2
  • Add-ons
2 years 8 months ago #328227 by liaskas
query field setup was created by liaskas
Hello

I am trying to create a field to use in a cb content module.

The job of this field is to return an online users list and the avatar of each user.

I made the following query:
SELECT DISTINCT a.userid AS auser, b.id AS bid, b.username AS busername, c.user_id AS cuser, c.avatar AS cavatar
FROM #__session a
LEFT JOIN #__users b ON a.userid = b.id
LEFT JOIN #__comprofiler c ON a.userid = c.user_id WHERE a.userid !=0 ORDER BY b.username ASC;

Tested the query in database and it works.

Now i take it to the field.

New query field and the above query in Parameters/Query.

Display Tab:

Multiple rows
Header: <table width='100%'>

Row: <tr><td width="30%"><img scr="/images/comprofiler/tn[column_cavatar]" width="40px" height="40px"></td><td width="70%">[column_busername] [cb:userfield field="avatar" userid="user_id" /]</td></tr>

Footer: </table>

and here is the result...



Can you please tell me what i am doing wrong?

The avatars are in place and accessible as images through the browser.

Thank you.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48424
  • Thanks: 8274
  • Karma: 1443
2 years 8 months ago #328231 by krileon
Replied by krileon on topic query field setup

The job of this field is to return an online users list and the avatar of each user.

We provide the CB Online Module included with CB for doing exactly that. Is that not sufficient for your needs? Your query doesn't seam to be doing any custom filtering to require needing to use CB Query Field.

Row: <tr><td width="30%"><img scr="/images/comprofiler/tn[column_cavatar]" width="40px" height="40px"></td><td width="70%">[column_busername] [cb:userfield field="avatar" userid="user_id" /]</td></tr>

Substitutions support nesting for some parts. The below for example will render their avatar safely.

[cb:userfield field="avatar" user="[column_id]" /]

Your query should only need to select the ID column as you'll be able to use this nesting behavior for all user parameters in substitutions. Please read our substitution documentation below carefully as it covers explaining how to properly use substitutions and the nesting behavior.

www.joomlapolis.com/documentation/279-community-builder/tutorials/18353-using-substitutions-throughout-cb


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.

  • liaskas
  • liaskas
  • OFFLINE
  • Posts: 382
  • Thanks: 36
  • Karma: 2
  • Add-ons
2 years 8 months ago #328232 by liaskas
Replied by liaskas on topic query field setup

We provide the CB Online Module included with CB for doing exactly that. Is that not sufficient for your needs? Your query doesn't seam to be doing any custom filtering to require needing to use CB Query Field.


I checked the cb online module but it does not return both username and avatar. It is the one or the other. Also i need to add an extra field of gender in the list when this is fixed.

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

  • liaskas
  • liaskas
  • OFFLINE
  • Posts: 382
  • Thanks: 36
  • Karma: 2
  • Add-ons
2 years 8 months ago - 2 years 8 months ago #328233 by liaskas
Replied by liaskas on topic query field setup
Even with this code i have no results...

<tr><td width="30%"><img scr=" www.domain/images/comprofiler/tn [column_cavatar]" width="40px" height="40px"></td><td width="70%">[column_busername]</td></tr>

returns:


If you check the url it is correct and you can open the avatar with a browser!
Last edit: 2 years 8 months ago by liaskas.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48424
  • Thanks: 8274
  • Karma: 1443
2 years 8 months ago #328237 by krileon
Replied by krileon on topic query field setup

I checked the cb online module but it does not return both username and avatar. It is the one or the other. Also i need to add an extra field of gender in the list when this is fixed.

It can display whatever you want it to display. Use the "User-text" parameter to completely customize what HTML is displayed per user displayed. This supports HTML and substitutions. You do not need a query field for this and that's really the hard way to be doing this. Example as follows.

User-text
Code:
<div> <div>[cb:userfield field="formatname" reason="list" /]</div> <div>[cb:userfield field="avatar" reason="list" /]</div> </div>

It however looks like you just want to display their canvas containers. CB Online Module includes a layout for doing exactly that. Under Advanced Options set Layout to "canvas".


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.

  • liaskas
  • liaskas
  • OFFLINE
  • Posts: 382
  • Thanks: 36
  • Karma: 2
  • Add-ons
2 years 8 months ago #328259 by liaskas
Replied by liaskas on topic query field setup
Thank you Krileon!

The "User-text" field solution did the trick and it shows pretty fine with the appropriate css classes.

ere is the last step we have to deal with but we can not find anything related in the substitutions tutorial or inside the forum

Right now we have this:

<div>
<div>[cb:userfield field="formatname" reason="list" /]</div>
<div>[cb:userfield field="avatar" reason="list" /]</div>
</div>

We need to continue in the second div with the following...

We also tried [cb:userfield field="GENDER" reason="list" /] and it returns the gender of each user successfully.

But we need to condition it like this:

if [cb:userfield field="GENDER" reason="list" /] is male... show a beautiful "M"
and
if [cb:userfield field="GENDER" reason="list" /] is female... show a beautiful "F"

F and M may be an img script.

I am sure that something like this can be done using substitutions! Can you please point us to the right direction?

Thank you

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

Moderators: beatnantkrileon
Powered by Kunena Forum