Gossamer Forum
Home : Products : Links 2.0 : Customization :

Add a field for language of ressource (flag-image?)

Quote Reply
Add a field for language of ressource (flag-image?)
Hi,
I know it must be possible, but actually I don't know exactly how to do it, so please please help me...:

Since I want to provide my visitors with both, English and German links, I want to add a field, that makes it possible to show in which language the website/resource is written...
Best would be, if it could be shown by an image that shows the corresponding flag.

If it could be done with one of the mods in the resources-section, please let me know which one I should use...

OFF TOPIC: Anybody out there, who did also see the solar eclipse? It was amazing folks... and I did have so much luck with the clouds!

BACK TO TOPIC: I would be very thankful if anybody out there could help me - not with the clouds but the additional field to Links
[|;-O)

Chiao,

Marc
Quote Reply
Re: Add a field for language of ressource (flag-image?) In reply to
Yes, this would be possible.

1) In your links.def file, you can another field, such as Language in the %db_def array.

You can use this field to create either a drop-down menu (select fields) or radio buttons. This will assist you in administrating your links.

2) Make a copy of your links.db file.

3) Upload the new links.def file.

4) After you have made these modifications, use the upgrade.pl file that is found somewhere in this forum (search for "upgrade" or something like that). This upgrade will allow you to put a new field accross your database, so that your database will not be corrupted.

5) In your link.html template (if you use templates), you can add in HTML code that will show a German or English Flag. (For this step, you will need to ask other people for how to set up the correct if/else
statements.)

I hope this helps.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Add a field for language of ressource (flag-image?) In reply to
Hi Eliot,

thanx for the instructions.
I will try what you told me today, hopefully it works...

If anybody knows how to do this modifikation to links.html (yes, I do use templates ;-)), please tell me...

Thanx in advnace to all,

Marc
Quote Reply
Re: Add a field for language of ressource (flag-image?) In reply to
Hi Eliot, hi y'all!

Well I did search the whole forum for that upgrade.pl, but I couldn't find it. Anybody knows where it is?

Actually my database is just a little evaluation-platform, so those entries will be deleted anyway before my site will go to public...
So is there the need to run upgrade.pl or do I maybe need it not at all?

If someone would be able to tell me how to add the flags to links.html - that would be great :-o)

I owe you what,

Marc
Quote Reply
Re: Add a field for language of ressource (flag-image?) In reply to
OK,

right now I modified links.def the following way, according to Eliot's and PHOENIX's instructions ( www.gossamer-threads.com/scripts/resources/Detailed/162.html ):

Code:
Language => [14, 'alpha', 0, 5, 1, '', '']


Do I have to modify any of the fields to read "English" and "German" or something like that?

Ah, and how do I call the from my template scripts?

Waiting for any reply - PLEASE!!! ;-)

Marc
Quote Reply
Re: Add a field for language of ressource (flag-image?) In reply to
Hi,

Ok, so you've added the field in. You might want to also put:

Language => 'English,German'

in db_select_fields in links.def so that in the admin you get a drop down list rather then a text box.

You should now be able to use <%Language%> in your templates as well.

Cheers,

Alex
Quote Reply
Re: Add a field for language of ressource (flag-image?) In reply to
Alex,

thanx for your help. I will be off for the weekend, but will try it Sunday when I'll be back....

Will I have to change the field that Phoenix describes as "default text for the admin on the field" to read 'English/German'...?

Is it also possible to add a drop down list to add.html? Would be a little less work administring the database ;-)

Ah, and there is one final question! Will I need to run upgrade.pl (see above) and if yes, could you please tell me where to find it, since I really glimpsed around the whole forum and couldn't find it (stupid me!).

Thanx again, and have a nice weekend,

Marc



[This message has been edited by Kodak (edited August 13, 1999).]

[This message has been edited by Kodak (edited August 13, 1999).]
Quote Reply
Re: Add a field for language of ressource (flag-image?) In reply to
Kodak,

I should have been more specific about which upgrade.pl file you need to use for changing fields in the links.def file.

The following Thread provides the codes for the upgrade.pl file that will automatically upgrade your links.db file with the new field in links.def:

www.gossamer-threads.com/scripts/forum/resources/Forum3/HTML/001090.html

The codes that you need to use for the upgrade.pl include:

Code:
#!/usr/bin/perl
# -------------------------------------------
#You must EDIT YOUR links.def script BEFORE entering these variable and running this script!
$field_default = ""; #Put the default value of the new field here. Leave Blank for no default.
$new_field = "7"; #Put the new field number here.
$total_fields = "15"; #Put the last field number here.
#Change these value to match your settings
require "../db_utils.pl";
require "../links.def";
#You shouldn't have to edit below this line
#------------------------------------------
$nfm1 = $new_field - 1;
$ENV{'REQUEST_METHOD'} and (print "Content-type: text/plain\n\n");
open (DB, "<links.db") or print "Unable to open links database 'links.db'. Reason: $!" and exit;
print "\tOpening output file . . .\n";
open (DBOUT, ">links2.db") or print "Unable to open output database. Make sure data dir is chmod 777 temporarily. Reason: $!" and exit;
print "\n\n\tProcessing records\n";
while (<DB> ) {
(/^#/) and next LINE; # Skip comment Lines.
(/^\s*$/) and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@rec_in = &split_decode($_);
# Copy ID, Title, URL, Date and Category
for $i (0 .. $nfm1) {
$rec_out[$i] = $rec_in[$i];
}
# Add New Field
$rec_out[$new_field] = "$field_default";
# Copy the rest of old links.db to new links2.db
for $i ($new_field .. $total_fields) {
$rec_out[$i + 1] = $rec_in[$i];
}
print DBOUT &join_encode(&array_to_hash(0, @rec_out));
}
print "\tDone.\n\n";
close DB;
close DBOUT;
print "Database saved it as links2.db.\n";
print "Change permissions back to 755 on the data directory.\n\n";
print "You must rename 'links2.db' to 'links.db before using with Links v2.\n";
print "It is recommend you save the original 'links.db' before renaming.\n\n";

First, make sure you have a "clean" backup of your links.db file before executing the upgrade.pl file.

Copy these codes and paste them into a NEW file, named upgrade.pl. (Note: You may need to change the extension to .cgi since some web servers are not configured to exectute .pl files.)

Also, change the following variables to the appropriate field numbers you have in the links.def file:

Code:
$new_field = "7";
$total_fields = "15";

Also, make sure that your Perl path in the first line is the correct path to your Perl program on your web server.

Then execute/run this file via your web browser.

Then save the links2.db to links.db file.

BTW: There is another Thread that explicitly discusses how to change the links.def file at the following web page:

www.gossamer-threads.com/scripts/forum/resources/Forum3/HTML/000865.html

Before you do this, I would recommend taking Alex's advise and create a select field for the "Language" field in the links.def file. Do the following:

1) Find %db_select_fields array in your links.def file.

2) Add in the following variable:

Code:
Language => 'German,French'

Yes, it is possible to add a new field into the Add Form. Yet, I know that there is another Thread that discusses this. May be you can find it via the search option or list all the Threads (in last year option) and then use Find in Page feature in your Web Browser. Search for words, like Add Form, Modifying Add Form, add.cgi.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited August 13, 1999).]

[This message has been edited by Eliot (edited August 13, 1999).]

[This message has been edited by Eliot (edited August 13, 1999).]
Quote Reply
Re: Add a field for language of ressource (flag-image?) In reply to
Hi Eliot,

thanx for your continued support....!!!

Tomorrow I will be able to try to modify my scripts and databases they way you told me to.
I hope that everything will turn out well.
Keep you informed, and see ya,

Marc
Quote Reply
Re: Add a field for language of ressource (flag-image?) In reply to
Eliot & Alex,

finally I did what you told me, and I think everything works well - at least until now ;-)

Everything's close to perfect, but there is one little (is it little?) modification left to do...

Alex wrote:
Quote:
You should now be able to use <%Language%> in your templates as well.

How could I call an image (FLAGs) instead of printing "English" or "German"...?

It would be nice if anyone could give me a hint - or better: instructions - on how to acchieve this.

Eliot and Alex, you're really great !!!

Thanx alot,

Kodak




[This message has been edited by Kodak (edited August 16, 1999).]
Quote Reply
Re: Add a field for language of ressource (flag-image?) In reply to
 
Code:
<if %Language% eq "German">
<img src="/path/to/germanflag.gif">
<%endif%>

<if %Language% eq "English">
<img src="/path/to/engflag.gif">
<%endif%>

I have not tested this...but give it a shot.

Smile

Good luck.

Regards,



------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Add a field for language of ressource (flag-image?) In reply to
Hmmmmmm.

I added the nested if mod to Templates.pm, but unfortunately it didn't help.

Would it be of any help, if I would publish my links.def here?
Well, here it is, at least a part of it (the changes I did):

Code:
# Database Definition: LINKS
# --------------------------------------------------------
# Definition of your database file.
%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Title => [1, 'alpha', 40, 75, 1, '', ''],
URL => [2, 'alpha', 40, 75, 1, 'http://', '^http|news|mailto|ftp'],
Date => [3, 'date', 15, 15, 1, \&get_date, ''],
Category => [4, 'alpha', 0, 150, 1, '', ''],
Description => [5, 'alpha', '40x3', 500, 0, '', ''],
'Contact Name' => [6, 'alpha', 40, 75, 1, '', ''],
'Contact Email' => [7, 'alpha', 40, 75, 1, '', '.+@.+\..+'],
Hits => [8, 'numer', 10, 10, 1, '0', '\d+'],
isNew => [9, 'alpha', 0, 5, 0, 'No', ''],
isPopular => [10, 'alpha', 0, 5, 0, 'No', ''],
Rating => [11, 'numer', 10, 10, 1, 0, '^[\d\.]+$'],
Votes => [12, 'numer', 10, 10, 1, 0, '^\d+$'],
ReceiveMail => [13, 'alpha', 10, 10, 1, 'Yes', 'No|Yes'],
Language => [14, 'alpha', 0, 10, 1, '', '']
);

# Database file to use -- defined in links.cfg.
$db_file_name = $db_links_name;
# Counter file to use -- defined in links.cfg.
$db_id_file_name = $db_links_id_file_name;
# The column name for the database key.
$db_key = 'ID';
# Database delimeter.
$db_delim = '|';
# Title used in admin output.
$html_title = 'Links Database';
$html_object = 'Link';

# Field Number of some important fields. The number is from %db_def above
# where the first field equals 0.
$db_category = 4; $db_modified = 3; $db_url = 2;
$db_hits = 8; $db_isnew = 9; $db_ispop = 10;
$db_contact_name = 6; $db_contact_email = 7; $db_title = 1;
$db_votes = 12; $db_rating = 11; $db_mail = 13;
$db_language = 14;

and further down in links.def I added what Alex told me to read:

Code:
%db_select_fields = (
isNew => 'Yes,No',
isPopular => 'Yes,No',
ReceiveMail => 'Yes,No',
Language => 'Deutsch,Englisch'
);

To precise it:
I added the nested if mod, but nothing changed from before. The links show up with description, new-image, rating-image, date, hits... but the field, where the image for the language should appear, is left empty!

Thanx in advance for any hint...!



[This message has been edited by Kodak (edited August 17, 1999).]
Quote Reply
Re: Add a field for language of ressource (flag-image?) In reply to
Hi Eliot,

sounds great !!!!
I will try to get it running now, just stay tuned, you will hear from me... :-)

Huhh, I'm so happy, so happy, so very very happy...

Thanx again

Kodak
Quote Reply
Re: Add a field for language of ressource (flag-image?) In reply to
Eliot & Alex,

today I modified link.html the way Eliot told me to, but unfortunately it won't work...

The links show up, but everything after the description is cut off. No rating, no hits... Before the modification everything worked well, so the problem must be located within the new code.

Here's a copy of my link.html:

Code:
<font face="verdana"color="#023599" size="-1"><ul><li><b><a class="link" href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>"><%Title%></a></b></font>
<%if isNew%>
<%new_img%>
<%endif%>
<%if isPopular%>
<font face="verdana"color="#023599" size="-1"><sup>TOP</sup>
<%endif%><br>
<br>
<%if Description%>
<font face="verdana"color="#023599" size="-1"><span class="descript"><%Description%></span>
<%endif%>
<br><small class="date">(Hinzugefügt: <%Date%> Hits: <%Hits%> #Stimmen: <%Votes%> Sprache:<if %Language% eq "Deutsch"><img src="http://www.photoblitz.de/images/germanflag.gif"><%endif%><if %Language% eq "Englisch"><img src="http://www.photoblitz.de/images/engflag.gif"><%endif%> ) <br><%rate_img%><a href="<%db_cgi_url%>/rate.cgi?ID=<%ID%>">[Ihre Wertung]</a></small></font></li>
</ul>


Sorry for asking you again, but do you maybe know, whats the problem here? Do you need further information? Should I also show you the modified code of my links.def?

Hmmm, it would be great if you'll continue to help me with that da...ed modification ;-)

So long,

Kodak


[This message has been edited by Kodak (edited August 17, 1999).]
Quote Reply
Re: Add a field for language of ressource (flag-image?) In reply to
Do you have the nested ifs mod installed? If you don't you have to put the <%if%> and <%endif%> tags on their own line. And I think
Code:
<if %Language% eq "Deutsch">
should be
Code:
<%if Language eq "Deutsch"%>
Quote Reply
Re: Add a field for language of ressource (flag-image?) In reply to
Thanx kiel1,

it's been a big step towards the final thing...

Right now it shows all the necessary lines and fields in a links-listing, BUT the image for the flag does not show up.

Here's the modified code of link.html:

Code:
<font face="verdana"color="#023599" size="-1"><ul><li><b><a class="link" href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>"><%Title%></a></b></font>
<%if isNew%>
<%new_img%>
<%endif%>
<%if isPopular%>
<font face="verdana"color="#023599" size="-1"><sup>TOP</sup>
<%endif%><br>
<br>
<%if Description%>
<font face="verdana"color="#023599" size="-1"><span class="descript"><%Description%></span>
<%endif%>
<br><small class="date">(Hinzugefügt: <%Date%> Hits: <%Hits%> #Stimmen: <%Votes%> Sprache:
<%if Language eq "Deutsch"%>
<img src="http://www.photoblitz.de/images/germanflag.gif">
<%endif%>
<%if Language eq "Englisch"%>
<img src="http://www.photoblitz.de/images/engflag.gif">
<%endif%>
)
<br><%rate_img%><a href="<%db_cgi_url%>/rate.cgi?ID=<%ID%>">[Ihre Wertung]</a></small></font></li>
</ul>

Do you have an idea what to do now to get the image?

One day it will work, I'm sure ;-P

Kodak

[This message has been edited by Kodak (edited August 17, 1999).]
Quote Reply
Re: Add a field for language of ressource (flag-image?) In reply to
Hi Kodak,

You will need to install the nested if mod into your Templates.pm file. I think it is in the Resource Center. If not, search for nested if in this forum. This mod will allow you to use nested variables within if statements.

Sorry for the confusion.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Add a field for language of ressource (flag-image?) In reply to
Hey Eliot,

great, this is close to a real time chat...
[;-)][;-)][;-)][;-)][;-)][;-)][;-)][;-)]

Ok, I will just turn to the resource center and have a look for the nested if stuff.

Hope it will work...

Oh, you don't have to excuse, I have to thank you even more times than there would be space in this forum ---- THANX !!!!

If one day I could help you, just tell me!

See ya later,

Kodak
Quote Reply
Re: Add a field for language of ressource (flag-image?) In reply to
Hmm...I am at a lost. I can't figure out why the image is not showing. Shucks!

Your links.def file seems to be configured correctly. Since you did install the nested if mod, then in all practical purposes, it should work.

May be someone else has an idea??

Sorry that I cannot be more helpful.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Add a field for language of ressource (flag-image?) In reply to
Hi Eliot,

anyway, thanx for all your help!!!!
I think we are real close to the solution.

I asked ALEX via eMail to check this thread again and give some advice what to do.

As I know him, he will give some help, quite soon.

If he will answer via eMail, I will post the solution right here, so in future everybody knows how to add a field AND an image...

I won't forget to mention that even if I contacted Alex, any help from anybody out there will be warmly welcome!

Come on....!

Thanx again to Eliot, Alex, kiel1
Quote Reply
Re: Add a field for language of ressource (flag-image?) In reply to
Hi Kodak,

First:

Quote:
<if %Language% eq "Deutsch">

won't work. You can't do comparision tests in the if's unfortunately (although it's a great idea!).

What you should do is in link.html:

<%if Language%>
<img src="/images/<%Language%>.gif">
<%endif%>

then make sure your images are named Deutsch.gif and English.gif.

Hope this helps,

Alex

Quote Reply
Re: Add a field for language of ressource (flag-image?) In reply to
Alex,

you're the greatest !!!!!


It works, wowowwowowowowowoow.......

Quote:
You can't do comparision tests in the if's unfortunately (although it's a great idea!).

Great idea, Eliot has had, heh?! Maybe something for a mod or Links 3.0...

Huh, the flag-stuff is a real cool improvement to my site and tonight I will think about some more fields that I could add ;-)

Btw., how do I get those nice smileys show up in UBB?

Thanx again folks for helping me to implement this new feature!

Kodak
Quote Reply
Re: Add a field for language of ressource (flag-image?) In reply to
You can check out the "faq" link at the top of the page for how to use UBB codes in these forums.

To create smiley faces...

Type in the : with ) next to each other:

Example: Smile

OR

Type in the ; with ) next to each other:

Example: Wink

(Sorry, Bobsie, from straying from the immediate topic at hand...just lending a helpful hand.)

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Add a field for language of ressource (flag-image?) In reply to
Hey Eliot,

look how fast I'm learning....

Wink Wink Wink Wink Wink Wink Wink Wink Wink Wink Wink Wink Wink Wink

And that's what Bobsie'll think of this ridiculous stuff:

Frown Frown Frown Frown Frown Frown Frown Frown Frown Frown Frown Frown Frown Frown

Thanx again for all, I need to get some sleep right now. Hope to see you again in the forum.

Ah, and don't forget: You're great!!!!

Good night,

Kodak
Quote Reply
Re: Add a field for language of ressource (flag-image?) In reply to
I'm just getting started trying to install links and configure it for my site.

This is the sort of thing I want to do with it. Does anyone have all the above modified files they could send to me so I don't have to go through all of the (detailed) changes above. As I say I've only just installed it so I don't have any data to mess up.

Thanks in advance