News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Colored username

Started by maly_pirat, September 22, 2009, 01:09:52 PM

Previous topic - Next topic

maly_pirat

Hi, i have one question about this mod -> click (Member color link)

How to make a color link?, because i bulid a new page (at smf) and i have SQL query and i get a username (user_id + usernick), but i don't know how to make a color this nick?

tyty1234

Can you show me your SQL Query? I may be able to assist you with this. :)
My Activity: Inactive
My Links: tyty1234's SMF Site | SMF Package Parser | SMF Helper | My Mods [5]
Subscribe to my SMF blog for updates
PMs for support will not be accepted, unless requested otherwise.

SA™

You just join members table with member_groups table using the id_group or id_post_group, then fetch online_group value for the group of member. A sample code would be.

$request = $smcFunc['db_query']('', '
SELECT
mem.id_member, mem.real_name, mg.online_color
FROM {db_prefix}members AS mem
LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = CASE WHEN mem.id_group = {int:reg_mem_group} THEN mem.id_post_group ELSE mem.id_group END)',
array(
'reg_mem_group' => 0,
)
);
$members = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
if (!empty($row['online_color']))
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
else
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';

$members[] = array(
'id' => $row['id_member'],
'name' => $row['real_name'],
'href' => $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => $link,
);
}

http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

greyknight17

maly_pirat, is this issue resolved now?

Any reason why you want to create your own query when the mod is ready for use after installing it?

Advertisement: