Welcome Guest [Log In] [Register]
Search Members Calendar | Rules ZB Code Index IF Code Index
ZBCode
  • Navigation
  • ZBCode
  • Coding Resources
  • Zetaboards Modifications
  • Country chooser
Hey, welcome to ZBCode, the premier coding forum for ZB. Here you fill find some of the best Invisionfree and Zetaboards Codes on the network! Unfortunately, you're sorta hovering around in guest mode at the moment; why not join in on the fun? Register an account and you can start accessing the wealth of resources we have available here. Enjoy your stay at ZBCode, and remember to tell all your friends about us; the more members, the more codes available. ;)

Interested in joining? Click here.


If you are already a member of ZBCode, feel free to login right here:

Username:   Password:
Locked Topic
  • Pages:
  • 1
  • 2
Country chooser; Like the IF one, but for ZB
Tweet Topic Started: Jun 18 2009, 03:04 PM (2,394 Views)
Garath531. Jun 18 2009, 03:04 PM Post #1


Posts:
156
Group:
Dedicated
Member
#3,232
Joined:
Jun 17, 2009
Hello everyone,
A while back I made a code for IF that adds a profile field that lets you choose your country. Now I have cleaned up that code for ZB.

How is this different than a normal custom profile field, you ask.

Well, there are three main reasons:

First, this code puts an actual image on the topic display and user information pages. Instead of showing the name of a country, it shows a flag for that country.

Second, this code lets you control the options. You, the admin, gets to determine which countries to allow.

Third, this code presents the options in the form of a drop down menu. Instead of forcing the users to fiddle with putting the correct information in a text box, it shows them the option in a nice little menu.


The installation might get a little bit complicated, depending on your experience level, but bear with me.
Spoiler: click to toggle

Step 1: Create a new profile field
It should:

  • Be named whatever you want to name it
  • Use the default max length (anything over 5 is fine really)
  • Have on registration set to yes
  • Admin only editable set to no
  • Show field in topics set to yes

Remember what you name it!
Step 2a: Add the code
Code:
 

<script type="text/javascript" src="http://z3.ifrm.com/35/125/0/p186954/zbcc20090717002.js"></script>
<script type="text/javascript">
ciname="choice_24479";
setCOpt("Country Name", "Flag Image URL", cdisplay.length)
</script>

Don't worry about changing anything when you put it in. I will tell you exactly what to change in the next two steps.
Step 2b: Change the variable "ciname"
For this step, you will need to view the source. Go to either the registration page (http://Board_URL/register/?c=1), or the Update profile page (http://Board_URL/home/?c=6) ad view the source. If you do not know how to do this, do a quick google search to easily find out! Now scroll down until you find the field that you added. It will look something like:
Code:
 

<input type='text' size='40' maxlength='200' name='choice_24479' autocomplete="off" />

It will be close to whatever you named it. If you named it "Country" with a maxlength of 200, there might be something in your source that looks like this:
Code:
 

<td class="c_desc">Country <small>Maximum length: 200</small></td>
<td><input type='text' size='40' maxlength='200' name='choice_24479' autocomplete="off" /></td>

Now for the tricky part.
Look at this line (of your source)
Quote:
 

<input type='text' size='40' maxlength='200' name='choice_24479' autocomplete="off" />

Copy the part in red, with the quotes, and find the line in the code that says this:
Quote:
 

ciname="choice_24479";

replace the part in red with what you copied.
I'm sorry if that was confusing; if you need help with this step (or any step for that matter), feel free to ask in this thread.
Step 3: Add the countries
Find this line in the code:
Quote:
 

setCOpt("Country Name", "Flag Image URL", cdisplay.length)

Change the parts in red. Copy and paste that line as many times a necessary!


If all went well, you should now have given the users the option to choose countries. Again, ask if you need any help! :)

Edit: Code updated.
--Garath531
Edited by Garath531., Jul 17 2009, 07:14 PM.
I'm back after an unexpected hiatus. If I've forgotten about a code I was working on for you, just drop me a PM and let me know. :)
Offline Profile Goto Top
 
Pilla Jun 18 2009, 05:30 PM Post #2
Member Avatar


Posts:
205
Group:
Dedicated
Member
#2,450
Joined:
Feb 26, 2009
Now Installing....

Edit: Where the code goes?

Edited by Pilla, Jun 18 2009, 05:38 PM.
Offline Profile Goto Top
 
Garath531. Jun 18 2009, 05:50 PM Post #3


Posts:
156
Group:
Dedicated
Member
#3,232
Joined:
Jun 17, 2009
Above the copyright
I'm back after an unexpected hiatus. If I've forgotten about a code I was working on for you, just drop me a PM and let me know. :)
Offline Profile Goto Top
 
Pilla Jun 18 2009, 05:59 PM Post #4
Member Avatar


Posts:
205
Group:
Dedicated
Member
#2,450
Joined:
Feb 26, 2009
thanks!!!
Offline Profile Goto Top
 
slayer766 Jun 18 2009, 10:43 PM Post #5
Member Avatar
Hello all

Posts:
1,653
Group:
Distinguished Coder
Member
#12
Joined:
Jul 9, 2008
Coding language
PHP
Ah, a conversion. Nice job man. :)
Offline Profile Goto Top
 
Hiddenzbu Jun 19 2009, 04:03 AM Post #6
Member Avatar


Posts:
130
Group:
Member
Member
#812
Joined:
Aug 31, 2008
Nice code :D. I'm not exactly sure why someone would want to ban any particular country though. Seems kinda mean.
Posted Image
Offline Profile Goto Top
 
Macjola Aug 27 2009, 03:58 AM Post #7


Posts:
1
Group:
Member
Member
#1,709
Joined:
Dec 6, 2008
I personally love the code, aswel as most others on our website. (hereby, thank you! ^_^ ) There is one problem I've experienced though:

I want to keep the list in alphabetical order to make it easier to find the countries.
Recently, I added two countries (Estonia, Latvia) and now everyone who had selected a country starting with an E-Z suddenly changed country.
I've noticed that, because I added those countries correctly in the alphabetical order, that everyone with a country E-K 'moved' one country up the list, and everyone with an L-Z moved two countries up the list.

Now I wonder, is there any way to have this save the country by name, rather than by position in the Script/dropdown menu?

Thanks in advance if anyone knows a solution!
Offline Profile Goto Top
 
Desire Law Aug 29 2009, 09:08 PM Post #8


Posts:
114
Group:
Dedicated
Member
#3,362
Joined:
Jul 26, 2009
Coding language
None
Thanks for this code! it comes in handy. :)
Offline Profile Goto Top
 
Nuke of Nukia Sep 2 2009, 09:41 PM Post #9
Member Avatar


Posts:
43
Group:
Member
Member
#2,919
Joined:
May 3, 2009
Coding language
HTML/CSS
I don't even know what it means by source...lol.
My board: UniverseWars
Offline Profile Goto Top
 
skylarkcob Oct 20 2009, 07:51 AM Post #10


Posts:
1
Group:
Member
Member
#986
Joined:
Sep 20, 2008
Thanks for code, good job!!!
Homepage: http://s1.zetaboards.com/khungtroingayxua
Email: Skylarkcob@gmail.com
Phone: 0974071428
Posted ImagePosted Image
Offline Profile Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
ZetaBoards - Free Forum Hosting
Fully Featured & Customizable Free Forums
Learn More · Sign-up for Free
Go to Next Page
« Previous Topic · Zetaboards Modifications · Next Topic »
Locked Topic
  • Pages:
  • 1
  • 2

Track Topic · E-mail Topic Time: 7:39 PM Jul 10
Hosted for free by ZetaBoards · Privacy Policy