Gossamer Forum
Home : Products : DBMan : Customization :

Hidden Fields

Quote Reply
Hidden Fields
Hi,

a friend of mine wants to have a database for the workshops he is offering. So an open database with no authorization and view part only. So far no problem, but now I like to have some additional fields, which are not visible to the normal customers. So something like, who has allready joined a workshop and so on.

But with the view part of the html.pl I only can give one sort of view (at least I have the feeling). So I can't differ between the customer view and the admin view. Ok, will work with the edit and add option, as these are not visible for the customer.

Does anyone has an idea, how this can be done?

Thanks and regards,
femu
Quote Reply
Re: [femu] Hidden Fields In reply to
Sure. It's actually quite simple.

If you want to use the autogenerate feature to create your display, set the field length to -2 on the fields that you want to be visible only to admins.

If you're creating your own display, it's a little more involved, but not much.

Let's say you have a display that looks like this:

Code:
print qq|
<table>
<tr><td>Name:</td>
<td>$rec{'Name'}></td></tr>
<tr><td>Userid:</td>
<td>$rec{'Userid'}</td></tr>
<tr><td>Address:</td>
<td>$rec{'Address'}</td></tr>
<tr><td>Gender:</td>
<td>$rec{'Gender'}</td></tr>
<tr><td>Favorite Color:</td>
<td>$rec{'Color'}</td></tr>
</table>
|;

and you want to make the Userid to be admin only. Change it so it looks like this:
Code:
print qq| <table>
<tr><td>Name:</td>
<td>$rec{'Name'}></td></tr>|;
if ($per_admin) {
print qq|
<tr><td>Userid:</td>
<td>$rec{'Userid'}</td></tr>|;
}
print qq|
<tr><td>Address:</td>
<td>$rec{'Address'}</td></tr>
<tr><td>Gender:</td>
<td>$rec{'Gender'}</td></tr>
<tr><td>Favorite Color:</td>
<td>$rec{'Color'}</td></tr>
</table>
|;

Notice the opening and closing brackets on the "if" statement and the print qq| and |; around the actual text that you want to print out.

If you have any problems with it and can't figure out the reason for the problem, be sure to come back and post the code you used.


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] Hidden Fields In reply to
Hi JPDeni,

thanks very much for the explanation. So I'm pretty sure one or the other will fit.


Kind regards,
femu
Quote Reply
Re: [femu] Hidden Fields In reply to
Hi,

just another question. Is it possible to fill fields in comparision with other fields? So let's say, I have a field called courses. And now I have a radion button selection, which says FREE, SHORT, FULL

Now I want to display a green card in the courses filed, when free is set, a yellow with short and red with full for example.

So I presume - if this is possible - some kind of an "if statement". Do you probably know, how I can manage such a thing?


Thanks,
femu
Quote Reply
Re: [femu] Hidden Fields In reply to
You can pretty much do anything with the display. :)

Here's what I find to be the easiest way to do what you want....

In the .cfg file, add some lines which define the image files you want to use, something like

$card{'FREE'} = 'http://url/to/your/images/green.gif';
$card{'SHORT'} = 'http://url/to/your/images/yellow.gif';
$card{'FULL'} = 'http://url/to/your/images/red.gif';

Make sure that you use the exact options for your radio field, including capitalization.

In the place in sub html_record where you want to show the flag, just use <img src="$card{$rec{'status'}}">

Replace status with the actual name of your radio field.

You can use "if" statements, but I think this is really cool Cool and also, if you should have to move your database, it's easier to change URLs if they're all in the .cfg file, rather than trying to find them in the html.pl file.


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.