Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Multi select display

Quote Reply
Multi select display
Hi,Smile

I have been able to set a thumbnail for each category. It looks the same way as the Lsql demo. I created an 'Image" field in the database and added the call to the image in the category template. So far so good. Shocked

Now to keep going with that idea, I wanted to be able to select one or several flags representing the language the linked web sites offer to visitors. I have been able to create a multi select check box with all the different languages available on the web. My problem is that I can not figure out how to display more than one image when a record has more than one selected check boxes for the language field. What do I need to do in the link template so that it displays all selected (checked) images in this language field?

Has anybody done something like this before?
Crazy


Also, is there a way to move fields around in the submit form? I would like to be able to type in the link title and then select it's thumbnail without having to scroll down the whole page. Every field I add to the database category or link table just appears at the end of the form. I would like to be able to adjust that. Is this possible?



Thank your time. Smile
Quote Reply
Re: [nt6] Multi select display In reply to
Hi,

you could create a global for that, like:

Flags =>
Code:
sub {
my $tags = shift;
my $imgtagstart = "<img src=\"/images/";
my $imgtagend = ".gif\">";
my $languages = $tags->{Language};
$languages =~ s/[\s#]/, /g;
$languages =~ s/\ben\b/$imgtagstart.en.$imgtagend/;
$languages =~ s/\bfr\b/$imgtagstart.fr.$imgtagend/;
$languages =~ s/\bde\b/$imgtagstart.de.$imgtagend/;

... and so on, then at the end:

my $output = $languages;
return $output;
}

This assumes that your database field is called 'Language' and that your images are located in the directory "/images" and that they are .gif files.

The blue characters are your country codes that will be replaced by the image tag.
You can then use the tag 'Flags' in your template.

The above is not tested with images (which means I'm not quite sure about the replacing with $imgtagstart and $imgtagend), but it works with words (i.e. replace "en" with "english", "fr" with "french" etc.).

Take a look at http://www.archaeologie-online.de/links/154/ (you may need to scroll down a bit to a link called "Archaeology in Romania", which is a multilingual site).

Andreas
-------------------------------------------------
http://www.archaeologie-online.de
Quote Reply
Re: [Digger] Multi select display In reply to
Thank you for your help.
I have just tried your suggestions.

The result is that I get broken images appearing where the image flags should be. That's a small step further.

When I look at the html I have an <img src=""> tag. I don't have a call to any path or image file.

So would you have any idea why this global can get the img src tag right, but no path to any file at all? Could this have something to do with the way I have set up the flag column in mysql, or is this a problem with the perl global?
Quote Reply
Re: [nt6] Multi select display In reply to
Hi,



It looks like the problem is coming from the $imgtagstart variable. I am not getting a path to the flag image file in the <img src=""> but I am getting the ".gif" as plain text after:

<!--definition of the language(s) --> &nbsp;&nbsp;Languages:
<IMG src="">.gif <!--definition of the language(s) end -->

I would really like to be able to do this with an image file.

Can someone with Perl knowledge help?



Thanks!
Quote Reply
Re: [nt6] Multi select display In reply to
Hi,

again without really trying it, but how about changing the appropriate lines of my last suggestion with something like

Code:
$languages =~ s/\ben\b/<img src="\/pix\/flags\/en.gif">/;
?

(Maybe the unescaped "/"-character in $imgstart is the problem in my first attempt?)

Andreas
-------------------------------------------------
http://www.archaeologie-online.de
Quote Reply
Re: [Digger] Multi select display In reply to
I am still getting the same kind of errors. We seam to be a small step away, there is probably only a small glitch in your script...
Quote Reply
Re: [nt6] Multi select display In reply to
Hmm,

you can change these lines to

Code:
$languages =~ s/en/<img src="\/pix\/flags\/en.gif">/;

and then - is your language field in the database called 'Images'?
Then you should change

my $languages = $tags->{Language};

to

my $languages = $tags->{Images};

Andreas
-------------------------------------------------
http://www.archaeologie-online.de
Quote Reply
Re: [Digger] Multi select display In reply to
   

I just tried and now I am getting errors:
Unable to compile 'Flags'. Reason: syntax error at (eval 16) line 8, near "s/en// my "Global symbol "$output" requires explicit package name at (eval 16) line 8.Global symbol "$output" requires explicit package name at (eval 16) line 9.


Please enable debugging in setup for more details.
Quote Reply
Re: [nt6] Multi select display In reply to
Hi nt6,

could you please post the code of your global?
And what is the name of your database field where you store the image names (or do you store the actual images in the database???)?

Andreas
-------------------------------------------------
http://www.archaeologie-online.de