Thread Rating:
  • 3 Vote(s) - 4.33 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Code Modification] 244 Countries Flags with Wiki Links in Postbit
#1
I was looking for away to have peoples flags show up in their post bits (if they wanted to, didn't want to use a IP based system and force it on users). After looking around it seems like everyone is charging for this feature, what I think is a bit wrong. So I decided to do my own but make it better than anything on offer and share it for free. My little way of saying thank you for all the free great plugins people have made for MyBB.

This has every know country and there flag. For an example for the UK it has flags for England, Scotland, Wales, Northern Ireland and United Kingdom.

Also the flag plugins people are charging for the images are pretty poor. Here is a couple of examples of the flags in this pack.

               

To install this download the attached flags.zip and extract it somewhere easy to find.

Then:

1. Upload the flags folder to root/images so the flag icons are in root/images/flags
2. In admincp create a new Custom Profile Field. (ACP > Configuration > Custom Profile Fields > Add New Profile Field)
  • Title: Country
  • Short Description: Select your Country Flag
  • Make is a "select box"
  • Paste the countrys.txt text into the select field (this is inside the flags folder)
  • Required? yes.
To make sure it looks neat make sure that Country is above Location.

3. Edit your Post Bit Template with the instructions below
(ACP > Templates & Style > Templates > "Theme in use" > Post Bit Templates > postbit or postbit_classic)

Find
<strong><span class="largetext">{$post['profilelink']}</span></strong> [Place Flag Code Here]

Place this bit of code next to it with a space between it (change the X of fidX to your custom profile ID for the country flag i.e fid4 instead of fidX)

[Image: workspace1067.png]

<a target="blank" href="http://en.wikipedia.org/wiki/Especial:Search?search={$post['fidX']}&fulltext=&go=Go" title="Look up {$post['fidX']} on wikipedia"
 style="cursor:help;" class="wiki"><img src="images/flags/{$post['fidX']}.png" ALIGN=ABSBOTTOM></img></a>

You should now be all set. If you don't want to use the Wiki links just remove that part from the PHP/HTML code. Copy from <img to just show the flags without the wiki link. The Wiki link is completely optional and does not effect the showing of the flags.

[Image: workspace1065.png]

I have no clue how to make plugins for MyBB so if someone wants to turn this into a plugin so people can easily install it please feel free to do so. All I ask for is for you to place a link in the description of the plugin to this thread.

Demo: http://forum.pinguyos.com

EDIT#

To add the flags to user profiles

Edit your Member Templates with the instructions below
(ACP > Templates & Style > Templates > "Theme in use" > Member Templates > member_profile)

Find
<span class="largetext"><strong>{$formattedname}</strong> [Place Flag Code Here]

Place this bit of code next to it with a space between it (change the X of fidX to your custom profile ID for the country flag i.e fid4 instead of fidX)

<a target="blank" href="http://en.wikipedia.org/wiki/Especial:Search?search={$userfields['fidX']}&fulltext=&go=Go" title="Look up {$userfields['fidX']} on wikipedia"
 style="cursor:help;" class="wiki"><img src="images/flags/{$userfields['fidX']}.png" ALIGN=ABSBOTTOM></img></a>

[Image: Selection_403.png]

To add the flags to memberlist page

Edit your Member Templates with the instructions below
(ACP > Templates & Style > Templates > "Theme in use" > Member List Templates > memberlist_user)

Find
<td class="{$alt_bg}">{$user['profilelink'] [Place Flag Code Here]

Place this bit of code next to it with a space between it (change the X of fidX to your custom profile ID for the country flag i.e fid4 instead of fidX)

<a target="blank" href="http://en.wikipedia.org/wiki/Especial:Search?search={$user['fidX']}&fulltext=&go=Go" title="Look up {$user['fidX']} on wikipedia"
 style="cursor:help;" class="wiki"><img src="images/flags/{$user['fidX']}.png" ALIGN=ABSMIDDLE></img></a>

[Image: Selection_406.png]


Attached Files
.zip   flags.zip (Size: 202.85 KB / Downloads: 558)
[Image: Jn29h.png]
DONATE TO PINGUY OS or show some love on Flattr.com
Reply
#2
Awesome plugin Pinguy. I'm a fan of your distro Smile Keep up the good job.
Reply
#3
Pinguy you have to submit it to the mods site first :p
I'm not here often, shoot a PM or whatever if you want my discord.
Reply
#4
Wow! This could go also @profile page and memberlist page!

Hats off Pinguy Smile


Edited: I was able to do it in the memberlist page but, I´m having problems at profile page LOL.

What would be the variable there?, I tried $memprofile but I´m able to see it myself, but for the rest of the users it shows X´s
Reply
#5
nice code, suitable for international forum Wink
Hello, Welcome to MyBB Indonesia to get local support
My 'Simple' Unique Plugin here Smile
Reply
#6
(02-12-2011, 05:55 PM)Sammyed Wrote: Wow! This could go also @profile page and memberlist page!

Hats off Pinguy Smile


Edited: I was able to do it in the memberlist page but, I´m having problems at profile page LOL.

What would be the variable there?, I tried $memprofile but I´m able to see it myself, but for the rest of the users it shows X´s

If it is showing the X its because you forgot to remove the X and add the ID number for the fid Smile
[Image: Jn29h.png]
DONATE TO PINGUY OS or show some love on Flattr.com
Reply
#7
(02-13-2011, 12:57 AM)pinguy Wrote: If it is showing the X its because you forgot to remove the X and add the ID number for the fid Smile

LMAO Big Grin

I wish I did that.

But no, what I did @ postbit template was:

Quote:<strong><span class="largetext">{$post['profilelink']}</span></strong> <img src="images/flags/{$post['fid10']}.png" ALIGN=ABSMIDDLE></img>

Works good. Wink

What I did for memberlist page @ memberlist_user template was:

Quote:<td class="{$alt_bg}">{$user['profilelink']} <img src="images/flags/{$user['fid10']}.png" ALIGN=ABSMIDDLE></img><br />

Works good Smile

Now as for profile page @ member_profile template:

Quote:<span class="largetext"><strong>{$formattedname}</strong> <img src="images/flags/{$memprofile['fid10']}.png" ALIGN=ABSMIDDLE></img><br /></span><br />

A red X right after the forum member. Confused, and when I get the properties to that red X image it says: "/images/flags/.png".

If the variable, in this case, is not $memprofile .Then what I should try with?. I already tried with $user, $profilefield, and some others LOL with no luck.

Thanks for replying Pinguy.

Cheers.
Reply
#8
thank you so much share information news cool nice!
Reply
#9
Hi,

I have this working, well sort of...

I set my flag in the control panel and it displays my flag, all good.

The problem is that my members that have not set a flag or Undisclosed get a broken image next to them, I have nearly 500 members so can't go through them all.

Is there a way to set all users automatically to Undisclosed unless they have selected otherwise.

I will have to remove this until it can be fixed.

Thanks,

Oliver
Reply
#10
(02-13-2011, 02:32 AM)Sammyed Wrote: If the variable, in this case, is not $memprofile .Then what I should try with?. I already tried with $user, $profilefield, and some others LOL with no luck.

{$userfields['fidX']}

(03-18-2011, 07:46 PM)bigoliver Wrote: ...set all users automatically to Undisclosed unless they have selected otherwise.

Run this in phpMyAdmin, replacing X with the actual custom field ID:
UPDATE `mybb_userfields` SET `fidX` = 'Undisclosed' WHERE `fidX` = '';
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)