Gossamer Forum
Home : Products : Links 2.0 : Customization :

Language flag Mod with checkbox. Add_error html

Quote Reply
Language flag Mod with checkbox. Add_error html
Hi all,
and sorry for earlier Post. I don't know what happend.

Denis (and Eliot for Template) provided very nice Mod to insert Language image-flag by adding resourse.
It was disscused here:

But if user makes a mistake (leaves field empty or wrong format) in add_error.html (as well as in modify.html and modify_error.html), there are no choosen language are shown. All checkboxes are empty.

I tried to adopt this solution for checkboxes, I found in:
But it didnot work for me with checkboxes.

Any ideas?

Thanks in advance

Quote Reply
Re: Language flag Mod with checkbox. Add_error html In reply to
Hi Ankom,

I haven't thought about his yet, because I think it's not too much to check the boxes again.
But if I had to do it, I'd put a little regular expression in site_html_templates.pl (in sub site_html_add_failure
) asking for the languages included in the string $in{'Language'} and returning something like $german = 'CHECKED';

Put up $german in your globals to use it with the templates and then put it into the checkbox-tag of the german language. Same do with all other languages you set up.

Haven't tested this yet I will maybe try to set it up for my LINKS later on. Let me know pls. if you succeed before I do, thanks.


Quote Reply
Re: Language flag Mod with checkbox. Add_error html In reply to
Glad to see you again, Denis.

Thanks for your suggestion.
I thought about this already, but was not sure.
I will try to your idea. I will post this for others if it will work.

Thanks again,

Quote Reply
Re: Language flag Mod with checkbox. Add_error html In reply to
Hi, me again. This was such a quick shot that I had to try it immediately. Boa, I'm getting better in PERL, it's working:

For non-templates just put this in site_html.pl, in sub site_html_add_failure right at the top:

if($in{'Sprache'} =~ /D/i) # If entry includes "D" (for Deutsch, meaning German) ...
{ $Dchecked = 'CHECKED'; } #... set variable $Dchecked to this value
if($in{'Sprache'} =~ /E/i) # If entry includes "E" (for English) ...
{ $Echecked = 'CHECKED'; }

[... and so on, and so on for each language you have...]
Then, where it reads in the show language mod (I mean where you put the <input>-tags for the checkboxes in the add-failure page)

<input type="checkbox" name="Sprache" value="D"><$d_graphic>
amend it to

<input type="checkbox" name="Sprache" value="D" $Dchecked><$d_graphic>
...and of course repeat this step for all other languages you have.

Wow, that's already all. It's working.
For non templates (if I understood that right) you'll have to put the reg.exp. into site_html_templates.pl, in sub site_html_add_failure for example after my ($errormsg).
Then setup all $Dchecked variables in %globals list at the top (Eliot, pls. correct me if I'm wrong, tks.) and last but not least put <%Dcheked%> and all the others at the apropriate place of your template (in the <input type="checkbox">-tags).


Quote Reply
Re: Language flag Mod with checkbox. Add_error html In reply to
Du bist einfach Klasse.

Great Hack Denis,

For Template Denis's Hack should be following:
(see earlier Thread about Language image-flag Mod http://gossamer-threads.com/...= collapsed&sb=5)

in site_html_templates.html in sub site_html_add_failure just after my ($errormsg) = shift;

if ($in{'Language'} =~/language1/i) { $lan1_checked = qq| checked |; }

if ($in{'Language'} =~/language2/i) { $lan2_checked = qq| checked |; }

if ($in{'Language'} =~/language3/i) { $lan3_checked = qq| checked |; }

And so on for any other languages

And then define (not in %globals at top of the site, but below somethere in print&load_template)

lang1_checked => $lang1_checked,
lang2_checked => $lang2_checked,
lang3_checked => $lang3_checked,

And so on

Finally, in your add_error.html:

<input type="checkbox" name="Language" value="language"<%lang1_checked%>> - <img src="path/to/images/language1_.gif">
<input type="checkbox" name="Language" value="language"<%lang2_checked%>> - <img src="path/to/images/language_2.gif">
<input type="checkbox" name="Language" value="language"<%lang3_checked%>> - <img src="path/to/images/language3_.gif">

I think the same should work for modify.html and modfy_error.html.