Is it possible to add an IMG tag in one of the data fields so that an image shows up in the output? Also, can I give that image an HREF tag so it is linkable?
Feb 21, 1999, 2:51 PM
Veteran / Moderator (8669 posts)
Feb 21, 1999, 2:51 PM
Post #2 of 14
Views: 3986
There are so many possible variations in what you might want, that it's hard to tell you how to do it exactly. But, yes, it is possible to do what you want if you do not use the autogenerate feature. You will have to build you html_record yourself.
I'll give you the more common uses of image tags and URL tags and you should be able to take it from there.
Let's say you have a field with the name of the image you want displayed. We'll call it "Image."
In html_record you would use something like
Similarly, to create a link, assuming you have a field called "URL" which has the full URL to the site you want to go to --
So, if you put the two together, you would have
<img src="http://full/url/to/image/directory/$rec{'Image'}">
</a></td>
------------------
JPD
[This message has been edited by JPDeni (edited February 21, 1999).]
I'll give you the more common uses of image tags and URL tags and you should be able to take it from there.
Let's say you have a field with the name of the image you want displayed. We'll call it "Image."
In html_record you would use something like
Code:
<td><img src="http://full/url/to/image/directory/$rec{'Image'}"></td>Similarly, to create a link, assuming you have a field called "URL" which has the full URL to the site you want to go to --
Code:
<td><a href="$rec{'URL'}">$rec{'URL'}</a></td>So, if you put the two together, you would have
Code:
<td><a href="$rec{'URL'}"> <img src="http://full/url/to/image/directory/$rec{'Image'}">
</a></td>
------------------
JPD
[This message has been edited by JPDeni (edited February 21, 1999).]
Apr 27, 1999, 8:33 AM
User (429 posts)
Apr 27, 1999, 8:33 AM
Post #6 of 14
Views: 3987
Well, you can and you can't. With the single database, it would be almost impossible without a hefty bit of hacking. In fact I'm not sure you even could.
That said, there's a very easy way around it. Just create another config and html file. For example, copy your default.cfg file and call the copy admin.cfg. Now, in the copy change:
require $db_script_path . "/html.pl";
to:
require $db_script_path . "/admin.pl";
or whatever your equivalent is. Next, make a copy of html.pl and call it admin.pl. Now you can remove the Image field from the original html.pl and make it an optional field, so when the user goes to add a record, voila - no Image field. And if you want to add an image, you can access the admin version with:
http://yourserver.com/path/to/dbman/db.cgi?db=admin
Obviously you can only do this if you're creating your own pages, it won't work with auto_generate. And you might also want make another couple of changes to admin.cfg for security. Probably the safest bet is to use a different .pass file and set your permissions to keep everybody out.
Cheers,
adam
Apr 27, 1999, 1:39 PM
Enthusiast (550 posts)
Apr 27, 1999, 1:39 PM
Post #7 of 14
Views: 3985
Thanks - I implemented your suggestion of an admin.pl and admin.cfg and the images work fine.
However, it has caused a different problem. I am using JPDeni's What's New mod - and when I click on the link to bring up the most recently added or modified records - get a list of images and incomplete text.
However, it has caused a different problem. I am using JPDeni's What's New mod - and when I click on the link to bring up the most recently added or modified records - get a list of images and incomplete text.
Apr 27, 1999, 1:50 PM
Veteran / Moderator (8669 posts)
Apr 27, 1999, 1:50 PM
Post #9 of 14
Views: 3999
There is another (and I think easier) way to go about this.
Use just one html.pl file. In sub html_record_form, in the place where you enter the name of the graphic, use the following:
if ($per_admin) {
print qq|<TR><TD>Image:</TD>
<TD><input type="text" name="Image" value="$rec{'Image'}"></TD></TR>|;
}
else {
print qq|<input type="hidden" name="Image" value="$rec{'Image'}">|;
}
print qq|
and then go on with your form definition.
Of course, you would need to change "Image" to the actual name of the field.
It would be possible for a user to download the form, change the value of the hidden field, load it back into his browser and add the record. I don't think that's very likely, though.
------------------
JPD
Use just one html.pl file. In sub html_record_form, in the place where you enter the name of the graphic, use the following:
Code:
|; # to close off a previous print qq| statement if ($per_admin) {
print qq|<TR><TD>Image:</TD>
<TD><input type="text" name="Image" value="$rec{'Image'}"></TD></TR>|;
}
else {
print qq|<input type="hidden" name="Image" value="$rec{'Image'}">|;
}
print qq|
and then go on with your form definition.
Of course, you would need to change "Image" to the actual name of the field.
It would be possible for a user to download the form, change the value of the hidden field, load it back into his browser and add the record. I don't think that's very likely, though.
------------------
JPD
Apr 27, 1999, 2:21 PM
Enthusiast (550 posts)
Apr 27, 1999, 2:21 PM
Post #10 of 14
Views: 3991
ok - I changed back to the single html.pl file according to JPDeni's last post.
It works as JPDeni said, however the "What's New" is still messed up.... the first few links are fine and then it looks like it begins to pull random text and lists it as links.
JPDeni - you are still listed in my database and you have all priviledges with exception of admin if you want to take a look at it.
The database is at http://cocoahighalumni.com/cgi-bin/dbman/db.cgi
It works as JPDeni said, however the "What's New" is still messed up.... the first few links are fine and then it looks like it begins to pull random text and lists it as links.
JPDeni - you are still listed in my database and you have all priviledges with exception of admin if you want to take a look at it.
The database is at http://cocoahighalumni.com/cgi-bin/dbman/db.cgi
Apr 27, 1999, 7:59 PM
Veteran / Moderator (8669 posts)
Apr 27, 1999, 7:59 PM
Post #11 of 14
Views: 3984
I didn't have a problem with "What's New," but I did have a problem with "List All." Lots of odd stuff there!
I'm wondering if you created a place in your old records for the new field. If there aren't enough field delimiters to match the number of defined fields, you're going to have a problem.
Assuming you added the "Image" field at the end of your database, you need to go through and add another delimiter to the end of each of the records that have not been recently modified. It's gonna be a bear to do, since some of them have the right number of fields and some don't.
You might be able to pull up each record individually that was last modified before you added the field and, without changing anything, click the "Modify Record" button. But with 900+ records, that's gonna take you a long time, too.
The only other thing I can suggest is to download the database and import it into something like MSAccess. It might take the data, even though there aren't the same number of fields in each row. This has some problems of its own, though.
BTW, adam, the "What's New" mod has been in the forum. I haven't gotten around to making a file for it. Guess I'll have to do that tonight.
------------------
JPD
I'm wondering if you created a place in your old records for the new field. If there aren't enough field delimiters to match the number of defined fields, you're going to have a problem.
Assuming you added the "Image" field at the end of your database, you need to go through and add another delimiter to the end of each of the records that have not been recently modified. It's gonna be a bear to do, since some of them have the right number of fields and some don't.
You might be able to pull up each record individually that was last modified before you added the field and, without changing anything, click the "Modify Record" button. But with 900+ records, that's gonna take you a long time, too.
The only other thing I can suggest is to download the database and import it into something like MSAccess. It might take the data, even though there aren't the same number of fields in each row. This has some problems of its own, though.
BTW, adam, the "What's New" mod has been in the forum. I haven't gotten around to making a file for it. Guess I'll have to do that tonight.
------------------
JPD
Apr 28, 1999, 12:34 AM
Veteran / Moderator (8669 posts)
Apr 28, 1999, 12:34 AM
Post #13 of 14
Views: 4008
Apr 28, 1999, 1:36 AM
Enthusiast (550 posts)
Apr 28, 1999, 1:36 AM
Post #14 of 14
Views: 3992
Thanks to both of you for your help ! It took me awhile to respond this last time because I remembered I hadn't made changes to the database file itself (adding the new field delimiter).
Whew !! 900+ records takes quite awhile - but everything is corrected now !
Thanks again - the help you give is always great !
Whew !! 900+ records takes quite awhile - but everything is corrected now !
Thanks again - the help you give is always great !