Gossamer Forum
Home : Products : DBMan : Customization :

Another way of saying it...

Quote Reply
Another way of saying it...
HI, regarding my last post, I think I know a better way of putting it:

I need to convert the categories into normal links (db.cgi?category=x, etc). NO problem there.

My question is how can I add an "if then" statement to see if the value of that field is "x" or "y"?

I've been trying something like this:

if ($rec{'category'} eq 'Baritone') {
print qq| <a href="baritones">Baritones!</a>
|;
}
print qq|

and so on...

any suggestions?

Quote Reply
Re: Another way of saying it... In reply to
Regarding this post...why duplicate Threads???

Regards,

Eliot Lee
Quote Reply
Re: Another way of saying it... In reply to
Hummmm...

Difficult to reply to this one.

Sometimes one tries to clarify his question by adding a bit more to it. Sometimes that person has a lot on his mind and posts a new message instead of a reply to the original question.

It is disappointing for me to see that there are jokers everywhere...even in an otherwise constructive and productive forum such as this.

I've really appreciated your help on past queries. And I much rather you took your time to answer (or ignore altogether) my post than to write silly answers (twice) to make a silly point.

To anyone else who may be willing, knowledgeable and available, I'll repeat my question:

I'm trying to put a link on my site.
This link is based on a select category.

This link should only appear if that category has a specific value.(ex: categories are car models. I should have a link to 'Ford' and to 'Chevrolet', but only if one of them exist.)

I know how to have data appear only if they are present (as per one of the mods)
I just don't know how to adapt the code so it fits the value of a select field.

I don't know Perl too well and I am having problems with the code.

I will REALLY apprecitate anyone who answers anything constructive.

Sincerely,

L.

Quote Reply
Re: Another way of saying it... In reply to
I'm not understanding what you are asking. If you are using the category in the link, db.cgi?category=x, why do you need an if/then query in the file using that same field?

It would seem to be more reasonable to have something like this: db.cgi?group=vocal

if ($rec{'category'} eq 'Baritone') {
print qq| <a href="baritonesthis is an incomplete url">Baritones!</a>
|;
}
if ($rec{'category'} eq 'Tenor') {
print qq| <a href="/tenors.html">Tenors!</a>
|;
}
print qq|


Perhaps I've misunderstood what you are trying to do.

Quote Reply
Re: Another way of saying it... In reply to
Hi, Karen.
First and foremost, thank you for your reply!
:)

Yes, it does make more sense. I've tried that as well today. For some reason, however, it does not seem to work.

I've been digging around the forum + webmagic's page and I found a post in which someone had it as "$in{'blah'} instead of $rec. Tried that also, and did not work.

I think the problem may be where I've place them.

Because I wanted the categories to be always present on the page, I put them under the "html globals" at the very beginning of the html.pl routine.

That's the only thing I can come up with. Do you know if this code has any restrictions regarding to where it should be placed?

I'll take a break to cool off my head and try again soon.

Thanks a bunch ;)

L.

Quote Reply
Re: Another way of saying it... In reply to
Hi, again. I searched the forum, the unnoficial pages and even your suggestion, but for some reasons it does not seem to work.

This is what I got:

1. on my html_page_top, I've included a little "niche" for the categories, (heres' the code):

...
<body bgcolor="white" text="black" leftmargin="4" topmargin="4" marginwidth="4" marginheight="4" link="#660000" vlink="#990000" onload="CSScriptInit();">





|;

if ($rec{'Category'} eq 'Tenor') {
print qq|<p>Tenors</p>|;
}


if ($rec{'Category'} eq 'Baritone') {
print qq|<p>Baritones</p>|;
}

if ($rec{'Category'} eq 'Designer') {
print qq|<p>Designers</p>|;
}

print qq|
...

For some reason, however, it does not seem to work. I took another person's advice (from the unnoficial site) and substituted the $rec for $in, but still not able to see anything. I don't get an error, just blank space.:(

Here's my config file,...maybe that will help:

code:
...
# Database Definition
# --------------------------------------------------------
# Definition of your database. Format is
# field_name => ['position', 'field_type', 'form-length', 'maxlength', 'not_null', 'default', 'valid_expr']

%db_def = (
ID => [0, 'numer', -1, 8, 1, '', ''],
FirstName => [1, 'alpha', 40, 255, 1, '', ''],
LastName => [2, 'alpha', 40, 255, 1, '', ''],
Specialty => [3, 'alpha', 40, 255, 0, '', ''],
Bio => [4, 'alpha', '40x5', 5000, 0, '', ''],
Curriculum => [5, 'alpha', '40x5', 5000, 0, '', ''],
Repertoir => [6, 'alpha', '40x5', 5000, 0, '', ''],
Homepage => [7, 'alpha', 40, 255, 0, 'http://', ''],
Photos => [8, 'alpha', 40, 255, 0, 'http://www.funkhouserartists.com/cgi-bin/gallery/gallery.cgi?Category=', ''],
Photos2 => [9, 'alpha', 40, 255, 0, 'http://www.funkhouserartists.com/cgi-bin/gallery/gallery.cgi?Category=', ''],
Date => [10, 'date', -2, 15, 1, &get_date, ''],
Category => [11, 'alpha', 0, 255, 1, '', ''],
Userid => [12, 'alpha', -2, 15, 0, '', ''],
Email => [13, 'alpha', 40, 255, 0, '', ''],
Filename => [14,'alpha',0,255,0,'',''],
Active=> [15, 'alpha', -1, 3, 0, 'Yes', 'Yes|No'],
CommName1 => [16, 'alpha', 40, 255, 0, '', ''],
CommUrl1 => [17, 'alpha', 40, 255, 0, 'http://', ''],
CommName2 => [18, 'alpha', 40, 255, 0, '', ''],
CommUrl2 => [19, 'alpha', 40, 255, 0, 'http://', ''],
CommName3 => [20, 'alpha', 40, 255, 0, '', ''],
CommUrl3 => [21, 'alpha', 40, 255, 0, 'http://', ''],
CommName4 => [22, 'alpha', 40, 255, 0, '', ''],
CommUrl4 => [23, 'alpha', 40, 255, 0, 'http://', ''],
CommName5 => [24, 'alpha', 40, 255, 0, '', ''],
CommUrl5 => [25, 'alpha', 40, 255, 0, 'http://', ''],
CommName6 => [26, 'alpha', 40, 255, 0, '', ''],
CommUrl6 => [27, 'alpha', 40, 255, 0, 'http://', ''],
CommName7 => [28, 'alpha', 40, 255, 0, '', ''],
CommUrl7 => [29, 'alpha', 40, 255, 0, 'http://', ''],
CommName8 => [30, 'alpha', 40, 255, 0, '', ''],
CommUrl8 => [31, 'alpha', 40, 255, 0, 'http://', ''],
CommName9 => [32, 'alpha', 40, 255, 0, '', ''],
CommUrl9 => [33, 'alpha', 40, 255, 0, 'http://', ''],
CommName10 => [34, 'alpha', 40, 255, 0, '', ''],
CommUrl10 => [35, 'alpha', 40, 255, 0, 'http://', '']
);

# The column name for the database key. Can be any column, but it must be unique!
# You can't have two records with the same key value!
$db_key = 'ID';
# Track the key? Should DBMan keep a counter of the next key to use? This isn't
# neccessary if you can guarantee that your entry in the key field will be unique
# (i.e. a userid).
$db_key_track = 1;
# Database delimeter.
$db_delim = '|';
# Use file locking (1 = Yes, 0 = No). Should be used, but won't work on Win95.
$db_use_flock = 1;
# Auto generate the html forms (1 = Yes, 0 = No).
$db_auto_generate = 0;
# Display Benchmarking Information (1 = Yes, 0 = No).
# use Benchmark; # Uncomment this line if benchmarking is used.
$db_benchmark = 0;
# Display Debugging Information (1 = Yes, 0 = No).
$db_debug = 0;

# Select fields. Field name => 'comma seperated list of drop down options'.
%db_select_fields = (
Category => 'Soprano,Mezzo-Soprano,Contralto,Countertenor,Tenor,Baritone,Bass-Baritone,Conductor,Composer,Stage Director,Designer,Narrator,Ensemble,Special Attraction,Instrumentalist'
);
...

Once again, I would be eternelly thankful for ANY feedback ;)
Thanks in advance :)

L.



Quote Reply
Re: Another way of saying it... In reply to
If this will work the way you're trying to use it, I do not know how to make it work Smile

The problem that you have is that $rec is not identified until after the database is accessed - the globals are being accessed first. You're calling data from the individual record but, the scripts do not know what the content of the record is yet.

The record content is being stored in my (%rec) = @_; # Load any defaults to put in the VALUE field. located in the html_record sub. Try moving your code below that point and see if the function will work then. At least that will let you know whether it's the code or the location.

Good luck!


Quote Reply
Re: Another way of saying it... In reply to
Hi, Karen...and thanks again.

Yes, what you've said makes total sense, but it still doesn't work.

I thought about that, too. I also tried putting it within the records view (short and long!) and nothing.

I was worried about the $rec not showing up at the homepage so I made the homepage a hidden search. When people actually go to the homepage, they are in actuality searching for all valid records (list all). It should show it then, right?

I don't know why. For some reason, the following code goes 100% invisible anywhere I put it.

if ($rec{'Category'} eq 'Tenor') {
print qq|<p>Tenors</p>|;
}


if ($rec{'Category'} eq 'Baritone') {
print qq|<p>Baritones</p>|;
}

if ($rec{'Category'} eq 'Designer') {
print qq|<p>Designers</p>|;
}

Any more suggestions? I'm about to give up :(

Thanks again

L.

Quote Reply
Re: Another way of saying it... In reply to
I have an idea:
is there any possible way to restrict even more the "Category MOD" so instead of looking for "Categories" in my field it would be looking for "Categories eq Tenor"?

If that would be the case (and yes, it is an ugly solution) all I would have to do is to duplicate the MOD many times on the page so it would reflect the desired order (ex: one cat. mod for Tenors, one for Altos, etc).

What do you think?

L.