Gossamer Forum
Home : Products : Links 2.0 : Customization :

Tiny mod to show site's language

Quote Reply
Tiny mod to show site's language
Here's my very first own (tiny) mod I ever made:

I wanted to show up a flag of the language a site is written in. See here what I mean:
www.eurabel.de/mopedfahrer/cgi-bin/search.cgi?query=www.mopedfahrer.de
It's the small German flag it's all about.

What do you have to do?

1) Add a dilimeter (usually |) at the end of each of your entries in links.db. Make sure you back up your orignal database before attempting to change it!!

2) Find %db_def in links.def. See the list of possible entries to a link. Add a comma at the end of the last line of possible entries to a link. Usually here:
Code:
ReceiveMail => [13, 'alpha', 10, 10, 1, 'Yes', 'No|Yes'],

3) Add the following line right below before mentioned line:
Code:
Sprache => [17, 'alpha', 5, 5, 0, '', '']
Watch out: see the 17? You've to change that most probably to 14, because it's got to be in a row with all the other items. I've added several new fields to my database, so for me it's been N°17.

Further: see the second 5 in that line? Change it to the max. number of flags you want to show. For example, if you want to show German, English and French flag, change it to 3.

4) I'm using non-templates. So, you've to open site_html.pl and find first of all this: You can put variables
Somewhere in a free line below put the path to your images, like this:
Code:
$d_graphic = 'img src="http://www.eurabel.de/mopedfahrer/bikerlinks/images/logos/d.gif" width="12" height="12" alt="Deutsch / Deutschland"';
$e_graphic = 'img src="http://www.eurabel.de/mopedfahrer/bikerlinks/images/logos/e.gif" width="12" height="12" alt="English / International"';
$a_graphic = 'img src="http://www.eurabel.de/mopedfahrer/bikerlinks/images/logos/a.gif" width="12" height="12" alt="Deutsch / Österreich"';
$s_graphic = 'img src="http://www.eurabel.de/mopedfahrer/bikerlinks/images/logos/s.gif" width="12" height="12" alt="Deutsch / Schweiz"';
Feel free to use my graphics which you'll find at the paths mentioned. Amend the path's to direct to your own logos! Overwrite the alt-tags with whatever you want.

Ok, now find sub site_html_link. Roughly 30 lines below you'll find the html that formats each link that's shown. Find if ($rec{'isPopular'}. Right below put this code:
Code:
# Show_Language MOD. (p) Denis Campbell 2000 -------------
if ($rec{'Sprache'}) { $output .= qq~<br><small class="date"> <b>Language:</b> ~;}
if($rec{'Sprache'} =~ /D/) # If entry includes "D" ...
{ $output .= qq~<$d_graphic> \n~; } # ...show German flag
if($rec{'Sprache'} =~ /S/) # Or if entry includes "S" ...
{ $output .= qq~<$s_graphic> \n~; } # ...show Switzerland flag
if($rec{'Sprache'} =~ /A/) # ...and so on ...
{ $output .= qq~<$a_graphic> \n~; }
if($rec{'Sprache'} =~ /E/)
{ $output .= qq~<$e_graphic> \n~; }
if ($rec{'Sprache'}) { $output .= qq~</small>~; }
# End Show_Language MOD ----------------------------------

If you're using templates-version, you've to make this amendments in site_html_templates.pl, in sub site_html_link. But don't ask me what to do, I've never used templates and don't want to think about that now. Wink

5) Let's go on with non-templates:
Next to find is $in{'Description'} in the sub site_html_add_form.
Right behind the table row (<tr>)for the description add this code:
Code:
<tr>
<td align="right" valign="top"></b>Site's language:</b></td>
<td><input type="checkbox" name="Sprache" value="D"><$d_graphic> -
<input type="checkbox" name="Sprache" value="S"><$s_graphic> -
<input type="checkbox" name="Sprache" value="A"><$a_graphic> -
<input type="checkbox" name="Sprache" value="E"><$e_graphic></td>
</tr>
Watch out: it makes a difference if you're using small or capital letters in the value-field of each <input>-tag! Also, be carefull when making manually changes in admin.cgi! Make sure your using coreectly either small or capital letters in the if-clause you entered in sub site_html_link
.


5a) Now, if you want the choosen languages to show on the confirmation page, you can use the variable $in{'Sprache'} at the apropriate place in sub site_html_add_success. I didn't want to, so I'll not explain the details now.

5b) The same goes for sub site_html_modify_form - make the same changes here as done before in sub site_html_add_form.

Ok, if I didn't forget a step and you followed all instructions, your admin.cgi should show up an additional field for each link, in which you'll find (in my case) a D or A or S or E, representing each one flag. Users may even choose several flags at a time.

If there's something wrong with my instrcutions let me know in this thread, 'cause for my LINKS it's working fine.

Have fun,
Denis

(Eliot, I got my PERL-book know Wink )


[This message has been edited by Denis (edited March 23, 2000).]

[This message has been edited by Denis (edited March 25, 2000).]
Quote Reply
Re: Tiny mod to show site's language In reply to
Uh...Don't take credit for other people's work. This is NOT your Mod...These codes have been provided in many other Topics and also there is a FAQ that covers how to do this.

Good about the Perl book...bad about taking credit from other people.

Smile Frown

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums