Gossamer Forum
Home : Products : DBMan : Customization :

Image Links

Quote Reply
Image Links
I saw a thread that discussed displaying images in place of text for links as explained by Eliot Lee.

The solution is as follows:

1) Add the following variable in your default.cfg file:
$wwwimage = qq|img src="/dir/image.gif" alt="" width="" height="" border="0"|;

2) Then in the sub html_record routine in the html.pl file, change the following codes:
<a href="$rec{'URL'}">$rec{'URL'}</a>

with the following:
<a href="$rec{'URL'}"><$wwwimage></a>

I can see how this works but how do you only display the image if no value is returned? I am pretty (actually very) new to all this and appreciate any help I get.

Thanks


Quote Reply
Re: Image Links In reply to
I think rather than using this:

$wwwimage = qq|img src="/dir/image.gif" alt="" width="" height="" border="0"|;

It may be easier to make that:

$wwwimage = '<img src="/dir/image.gif" alt="" width="" height="" border="0">';


Then in the sub html_record routine you could just enter the variable as: $wwwimage

If you only want to print the image if there is a value you could use:

if ($rec{'URL'}) { print qq| <A HREF="$rec{'URL'}">$wwwimage</A> |; }

Be sure to close off you print statement before the line and then begin again for additional lines like this:

|;
if ($rec{'URL'}) { print qq| <A HREF="$rec{'URL'}">$wwwimage</A> |; }
print qq|

Hope this helps


Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Image Links In reply to
LoisC
You truly are a maven
Thanks It works great!
However the image appears even when the returned value null.
Any ideas why the if statement doesn't work?
Cesar





Quote Reply
Post deleted by LoisC In reply to
Quote Reply
Re: Image Links In reply to
Cesar, do you have a default http:// entered for the field definition? If so, you may want to change the code to something like this:

if ($rec{'URL'} gt $db_defaults{'URL'}) { ...

The rest of LoisC's code.

~ Karen



Quote Reply
Post deleted by LoisC In reply to
Quote Reply
Re: Image Links In reply to
In Reply To:
Who is Cesar?

Or...he could just get rid of the default http://
Cesar is the person who was looking for an answer to a question!

Personally, I like having the default http:// if for no other reason than simply to help in educating people that a complete URL includes the http://

By comparing the call to the default, the display can be controlled.

In Reply To:
Uh...my codes do work just fine, LoisC.
True, although LoisC's code works too. It's kinda nice to see several variations on completing the task.

Quote Reply
Re: Image Links In reply to
Basically what I have is a value being returned that is the name of a document.
I then take this and place it within to variables that will complete the url to the document.

In default.cfg I have:

$docimage = '<img src="path/to/gif/word.gif" border="0">';


So in html_record I have:

my $docurlstart = '<a href="http://path/to/doc/dir/';
my $docurlend = '" target="_blank">';


|;
if ($rec{'docname'}) { print qq| docurlstart$rec{'docname'}$formattedend$docurlend</A> |; }
print qq|

I really didn't change much, so I can't see why it would display when nothing is returned.
Thanks

Quote Reply
Re: Image Links In reply to
Thanks Karen that did the trick.

This is what I did for the empty fields.

if ($rec{'URL'} gt " ") { ...

Cesar




Quote Reply
Post deleted by LoisC In reply to
Quote Reply
Re: Image Links In reply to
A more condensed version would be:

rather than using:

my $docurlstart = '<a href="http://path/to/doc/dir/';
my $docurlend = '" target="_blank">';

is to perhaps use:

$wwwimage = '<img src="http://path/to/doc/dir/image.gif" alt="" width="" height="" border="0">';

And then for your html_record_form use:

if (length($rec{'URL'}) > 7) {
print qq|Web URL: <A HREF="$url{'URL'}" target="blank">$wwwimage</A>

What this would do is to display the image and url link only if there is more than just http:// within the field entry.



Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Image Links In reply to
thanks lois...
but i don't keep the url in a field ...
all i keep is a doc name...
if ther eis no doc available it remasins blank...
so i need to check for an empty field...
thanks for the tip...
cesar