Skip to Content Skip to Menu

mysql field cb2

  • krileon
  • krileon
  • ONLINE
  • Posts: 48478
  • Thanks: 8282
  • Karma: 1443
9 years 10 months ago - 9 years 9 months ago #256254 by krileon
Replied by krileon on topic mysql field cb2
Yes, you'll need 2 fields. 1 for edit display (your query select) and 1 for profile display (the query field). The reason for this is you are not storing to CB the team logo as the select fields value so you need to grab it using cb query field. So if you're storing the team id then your query would be the below.

Field Name: cb_team_logo
Query:
Code:
SELECT `name`, `logo` FROM `#__team` WHERE `id` = '[cb_team]'
Output: Single Row
Columns: Multiple Columns
Display: Custom
Custom:
Code:
<img src="[column_logo]" alt="[column_name]" />

cb_team being your query select field where they've selected a team. Your query select would be configured as follows.

Field Name: cb_team
Query:
Code:
SELECT `id`, `name` FROM `#__team`
Value Column: id
Label Column: name


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.
Last edit: 9 years 9 months ago by krileon.

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

  • Giankomat
  • Giankomat
  • OFFLINE
  • Posts: 56
  • Thanks: 0
  • Karma: -1
  • Add-ons
9 years 9 months ago #256522 by Giankomat
Replied by Giankomat on topic mysql field cb2
thanks, I forgot to say I figured it out exactly like you said. :)

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

  • Giankomat
  • Giankomat
  • OFFLINE
  • Posts: 56
  • Thanks: 0
  • Karma: -1
  • Add-ons
9 years 9 months ago #256749 by Giankomat
Replied by Giankomat on topic mysql field cb2
uhm there is an easy way to avoid broken images if the team doesn't have a logo? (the db field is empty)

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48478
  • Thanks: 8282
  • Karma: 1443
9 years 9 months ago #256775 by krileon
Replied by krileon on topic mysql field cb2
If you're using latest CB Query Field there shouldn't be broken images as it won't output anything if the query returns no results. If you mean that there is a result, but no logo yet then you need to add to your query WHERE statement to check that there's a logo. Example as follows.

Code:
SELECT `name`, `logo` FROM `#__team` WHERE `id` = '[cb_team]' AND `logo` != ''


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.

  • Giankomat
  • Giankomat
  • OFFLINE
  • Posts: 56
  • Thanks: 0
  • Karma: -1
  • Add-ons
9 years 9 months ago - 9 years 9 months ago #256943 by Giankomat
Replied by Giankomat on topic mysql field cb2
thanks, but in this way I don't see the field at all.
Here the situation: some teams have the logo, some other doesn't.
In case they don't have it I want to show the team name.
Last edit: 9 years 9 months ago by Giankomat.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48478
  • Thanks: 8282
  • Karma: 1443
9 years 9 months ago - 9 years 9 months ago #256970 by krileon
Replied by krileon on topic mysql field cb2
You can't have substitution IF statements on extra substitutions (so the columns can't be used in IF substitutions). So what you're wanting isn't possible without a 3rd field. The 3rd field would purely be querying for a logo. This would allow you to condition off that 3rd field so you could do something like the below.

Field Name: cb_team_logo_url
Query:
Code:
SELECT `logo` FROM `#__team` WHERE `id` = '[cb_team]'
Output: Single Row
Columns: Single Column

The above would output the logo URL. Place it on a tab in a not shown on profile position so it can be used for substitutions only as needed. Next in cb_team_logo you should be able to adjust the custom output as follows.

FROM:
Code:
<img src="[column_logo]" alt="[column_name]" />
TO:
Code:
[cb:if cb_team_logo_url!=""]<img src="[column_logo]" alt="[column_name]" />[/cb:if] [cb:if cb_team_logo_url=""][column_name][/cb:if]

Please understand the above is just an example. I've no idea your database structure so I've no idea if the queries will even work. I have not tested the above. You may need to make adjustments.

An alternative is to edit your query and have the query it self format the <img tag, which would eliminate the need for a 3rd field.


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.
Last edit: 9 years 9 months ago by krileon.

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

Moderators: beatnantkrileon
Powered by Kunena Forum