Customizing SMF > SMF Coding Discussion
Help me write this code...
Liam_michael:
--- Quote from: Labradoodle-360 on March 12, 2012, 02:11:10 PM ---IchBin did. He told you exactly what you need to do.
--- End quote ---
I understand what he means, but I don't know how to put it together. I'm really not a computer programmer.
IchBin™:
Don't be afraid to try Liam_michael. You'll never learn if you don't. If you get stuck you post your code and people can show you how to fix things.
--- Code: (add above the code you posted) ---$myquery = $smcFunc['db_query']('', '
SELECT id_group
FROM {db_prefix}members
WHERE id_member = {int:id_mem}',
array('id_mem' => $row['first_id_member'])
);
$style = '';
$mygroups = array(1,3);
$groups = array();
while($row2 = $smcFunc['db_fetch_row']($myquery))
$groups[] = $row2[0];
if(array_intersect($groups, $mygroups))
$style = 'style="color: red;"';
--- End code ---
You can of course change the style color to be anything you want.
--- Code: (Find in your code) ---'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['first_subject'] . '</a>'
--- End code ---
--- Code: (Replace with this) ---'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0" ' . $style . '>' . $row['first_subject'] . '</a>'
--- End code ---
Labradoodle-360:
He's not using SMF 2.0 as he said above, so the code would have to utilize db_query() rather than $smcFunc, and mysql_fetch_assoc() rather than $smcFunc['db_fetch_assoc']().
Furthermore, it may be more simple to use loadMemberData and loadMemberContext in this scenario.
Liam_michael:
Don't be afraid to try Liam_michael. You'll never learn if you don't. If you get stuck you post your code and people can show you how to fix things.
Thanks for the encouragement, IchBin™. It's just that my knowledge in php is *very* limited. I know how to create simple arguments, but that's just it. I tried your code and I forgot to mention it's for 1.x.
IchBin™:
There's no need to use loadMemberData() when all your doing is grabbing the groups. You'll be pulling in much more information than you need.
Code change for SMF 1.1.x
--- Code: ---$myquery = db_query("
SELECT id_group
FROM {$db_prefix}members
WHERE id_member = ". $row['first_id_member'], __FILE__, __LINE__);
$style = '';
$mygroups = array(1,3);
$groups = array();
while($row2 = mysql_fetch_row($myquery))
$groups[] = $row2[0];
if(array_intersect($groups, $mygroups))
$style = 'style="color: red;"';
--- End code ---
--- Code: ---'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0" ' . $style . '>' . $row['firstSubject'] . '</a>'
--- End code ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version