Skip to Content Skip to Menu

🌟 CB Editor Assistant 1.0.0 is here! Discover our new AI Joomla Plugin that wrote its story! (and this banner!)
Start at just $12.50/month* or 💸 save 30% with our 🛍️ Black Friday Intro Offer for your subscription's lifetime
🎉 Black Friday sale is here! Great savings on professional and developer memberships! Get 25% off now with code BLACK-FRIDAY-2024!

[SOLVED] Hyperlink to profile using query select.

6 years 1 month ago - 6 years 3 weeks ago #307827 by RebeccaWool
Hello,

I am very new to query select and this question maybe very basic but, I have spent a day searching for answers and am now stuck.

Using CB query field, I want to show a user's name and have it link to their profile page.

So far I have:
Code:
SELECT CONCAT_WS(" ", firstname, lastname) AS whole_name FROM traincomprofiler where cb_role = "team_leader_adult"

Now, how do I make that a hyperlink to the resulting user's profile please?
Also, if there are more than one user's to be listed, how to make each name on a new line?

Please note: I am blind, no useful sight and rely totally on Voiceover (screen reader) to access my computer. This makes it really difficult to understand some coding text and images such as screen shots don't convey any information. So if I ask you to clarify something, it is not because I'm being a pain, it's because my computer hasn't made it clear! Thanks for your understanding.

Life is a constant learning curve and I've just started out!
Last edit: 6 years 3 weeks ago by krileon. Reason: Added [SOLVED] tag to subject

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48560
  • Thanks: 8292
  • Karma: 1445
6 years 1 month ago #307838 by krileon
Replied by krileon on topic Hyperlink to profile using query select.
Should be doable as long as you also grab their user id in your query. The following should work for your required SQL and the display code.


Query:
Code:
SELECT `id`, CONCAT_WS( " ", `firstname`, `lastname` ) AS whole_name FROM `#__comprofiler` WHERE `cb_role` = "team_leader_adult"
Output: Multiple Rows
Row:
Code:
<div><a href="index.php?option=com_comprofiler&view=userprofile&user=[column_id]">[whole_name]</a></div>


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.
The following user(s) said Thank You: RebeccaWool

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

6 years 3 weeks ago #308334 by RebeccaWool
Replied by RebeccaWool on topic Hyperlink to profile using query select.
Hello Kyle,

Thanks for the above, it "sort" of works.

It returns:

whole_name

Which links to the user's profile but obviously isn't displaying the actual name of the person.

I have adapted the query to:
Code:
select t2.id, CONCAT( " ", t2.firstname, t2.lastname) as whole_name FROM #__comprofiler as t1, #__comprofiler as t2 where t1.cb_service_name = t2.cb_service_name and t2.cb_role = "team_leader" and t1.user_id = [user_id]

This query returns the correct user(s) profile when used in conjunction with the:
Code:
<div><a href="index.php?option=com_comprofiler&view=userprofile&user=[column_id]">whole_name</a></div>

But still displays "whole_name".
Having researched on various sites and resources, I thought the query might need a variable in order to pass the result to the hyperlink and came up with:
Code:
declare name varchar (25) set name = t2.id, CONCAT( " ", t2.firstname, t2.lastname) FROM #__comprofiler as t1, #__comprofiler as t2 where t1.cb_service_name = t2.cb_service_name and t2.cb_role = "team_leader" and t1.user_id = [user_id]

But that returns an error.
Then I tried placing the name of the field in the hyperlink row as follows:
Code:
<div><a href="index.php?option=com_comprofiler&view=userprofile&user=[column_id]">[cb_team_leader]</a></div>

But this crashed the server big style! Please don't tell my hosting provider it was me!!!!

How do I fix the issue and have it display the user's name correctly please?

Many thanks.

Life is a constant learning curve and I've just started out!

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48560
  • Thanks: 8292
  • Karma: 1445
6 years 3 weeks ago #308338 by krileon
Replied by krileon on topic Hyperlink to profile using query select.
You need to use [column_whole_name]. Anytime you're substituting in columns from your query be sure to use the [column_COLUMN_NAME] structure.


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.
The following user(s) said Thank You: nant, RebeccaWool

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

6 years 3 weeks ago #308345 by RebeccaWool
Replied by RebeccaWool on topic SOLVED: Hyperlink to profile using query select.
Kyle,

You are a genius!

It's perfect, thank you for all your help.

Life is a constant learning curve and I've just started out!
The following user(s) said Thank You: nant, krileon

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

Moderators: beatnantkrileon
Powered by Kunena Forum