Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: FragaCampos on October 22, 2008, 06:40:13 PM

Title: Help on flags mod
Post by: FragaCampos on October 22, 2008, 06:40:13 PM
Hello there.
Dunno if this is the right place to ask, but i hope it's ok  O:)

Can anyone check if this (http://www.simplemachines.org/community/index.php?topic=106060.0) mod can be modified to had a column in the memberlist with the flag of each member? Does anyone knows if this is "easy" to implement?

Thanks anyhow.
Title: Re: Help on flags mod
Post by: D M G on October 24, 2008, 07:13:33 PM
The memberlist is a real pain to mess with!
Title: Re: Help on flags mod
Post by: [SiNaN] on October 25, 2008, 05:09:46 AM
Memberlist.php

Find:

'posts' => array(

Replace:

'country' => array(
'label' => 'Country'
),
'posts' => array(


This will add the column to the template.

Memberlist.template.php

Find:

// Assuming there are members loop through each one displaying their data.

Replace:

$flags = CountryFlag();

// Assuming there are members loop through each one displaying their data.


This will load all the flags and their information.

Find:

<td class="windowbg2" width="15">', $member['posts'], '</td>

Replace:

<td class="windowbg2" width="15">', $member['posts'], '</td>
<td class="windowbg2" width="15">', !empty($member['options']['country']) ? '<img src="' . $settings['default_theme_url'] . '/images/flags/' . $member['options']['country'] . '.png" alt="' . $flags[$member['options']['country']] . '" />' : '', '</td>


This will output the info for every user.

Find:

<td colspan="12">';

Replace:

<td colspan="13">';

Find:

<td colspan="12" class="', empty($settings['use_tabs']) ? 'catbg' : 'titlebg', '">';

Replace:

<td colspan="13" class="', empty($settings['use_tabs']) ? 'catbg' : 'titlebg', '">';

Find:

<td colspan="12" class="windowbg">', $txt[170], '</td>

Replace:

<td colspan="13" class="windowbg">', $txt[170], '</td>

Find:

<td class="titlebg" colspan="12">', $txt[139], ': ', $context['page_index'], '</td>

Replace:

<td class="titlebg" colspan="13">', $txt[139], ': ', $context['page_index'], '</td>

Above are the template colspan fixes.
Title: Re: Help on flags mod
Post by: FragaCampos on October 26, 2008, 09:56:54 AM
First of all, thank you very much for helping on this  ;D

I made all the changes and it works, but with a minor problem. As you can see in the screenshot, the columns "country" and "posts" are switched. Help?  :P

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fimg232.imageshack.us%2Fimg232%2F7412%2Fsemttulozk9.th.jpg&hash=8820fc36a70d48a6946e85763be8012e9bc3d4fe) (http://img232.imageshack.us/my.php?image=semttulozk9.jpg)(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fimg232.imageshack.us%2Fimages%2Fthpix.gif&hash=d27b408464bb450c652915767fef18b87f5ade7d) (http://g.imageshack.us/thpix.php)
Title: Re: Help on flags mod
Post by: [SiNaN] on October 27, 2008, 06:28:14 AM
Sorry.

Now,

MemberList.template.php

Find:

         <td class="windowbg2" width="15">', $member['posts'], '</td>
         <td class="windowbg2" width="15">', !empty($member['options']['country']) ? '<img src="' . $settings['default_theme_url'] . '/images/flags/' . $member['options']['country'] . '.png" alt="' . $flags[$member['options']['country']] . '" />' : '', '</td>


Replace:

         <td class="windowbg2" width="15">', !empty($member['options']['country']) ? '<img src="' . $settings['default_theme_url'] . '/images/flags/' . $member['options']['country'] . '.png" alt="' . $flags[$member['options']['country']] . '" />' : '', '</td>
         <td class="windowbg2" width="15">', $member['posts'], '</td>
Title: Re: Help on flags mod
Post by: FragaCampos on October 27, 2008, 03:35:32 PM
Thanks a million [SiNaN]. For your help and readiness.
I'lll share this piece of code of yours in the mod section.
Title: Re: Help on flags mod
Post by: CraigPal on October 27, 2008, 10:28:17 PM
Thanks bunches!

The only problem I have is that I get an error when trying to sort by country:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0, 50' at line 5
File: /home1/rawpaleo/public_html/Sources/Memberlist.php
Line: 345


Craig

_________________
Raw Paleolithic Diet (http://www.rawpaleodiet.com)
Title: Re: Help on flags mod
Post by: FragaCampos on October 28, 2008, 09:12:38 AM
It's true, i didn't notice that...
Title: Re: Help on flags mod
Post by: [SiNaN] on October 28, 2008, 10:54:35 AM
Missed that, sorry.

Memberlist.php

Find:

'posts' => array(
'down' => 'mem.posts DESC',


Replace:

'country' => array(
'down' => 'ISNULL(tc.value) ASC, tc.value ASC',
'up' => 'ISNULL(tc.value) DESC, tc.value DESC'
),
'posts' => array(
'down' => 'mem.posts DESC',


Find:

LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))" : '') . "

Replace:

LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))" : '') . ($_REQUEST['sort'] === 'country' ? "
LEFT JOIN {$db_prefix}themes AS tc ON (tc.ID_MEMBER = mem.ID_MEMBER AND tc.variable = 'country')" : '') . "
Title: Re: Help on flags mod
Post by: FragaCampos on October 28, 2008, 09:31:41 PM
Works great, thanks once more [SiNaN]!

PS: Hope that depression goes away soon...
Title: Re: Help on flags mod
Post by: Andrijachi on January 15, 2009, 09:32:53 AM
Thanks for this ... working perfectly!